Excel - logic for skipping rows in a formula - excel

I am trying to do the following via a formula rather than VBA/macro (i do not want a copy/paste special solution as i need more control). is it possible to:
I have a column in which there are some blank rows and some rows with values. let's call that column A. In column b, i only want to copy the cells if the column A has a value. if it doesn't, i want it to skip to the next cell in column A, but stay on on the same cell for column b.
Column A
1
2
[blank]
4
[blank]
6
i want column b output to be (but with no blank rows). this would imply that somehow the formula would need to loop and have some loop skipping logic:
1
2
4
6
Normally i would just set cell B1 = A1 to copy it over, but since i want to skip rows that are blank in column A, i'm not sure what to do besides right a macro. Can i use an array or any other creative solution? Eventually, i would also use this for items with specific values (not just blanks).
thanks!

Generically in cell C2 copied down....
=IFERROR(INDEX(Range,SMALL(IF(Range=criteria,ROW(Range)-MIN(ROW(Range))+1),ROWS(C$2:C2))),"")
confirmed with CTRL+SHIFT+ENTER
so here if your data is in A1:A10 and you want results from B1 down
=IFERROR(INDEX(A$1:A$10,SMALL(IF(A$1:A$10<>"",ROW(A$1:A$10)-ROW(A$1)+1),ROWS(B$1:B1))),"")
confirmed with CTRL+SHIFT+ENTER and copied down
when you run out of data you get blanks

For BLANKS, just copy ColumnA to ColumnB, select ColumnB, Find & Select, Go To Special..., Blanks, right-click one of the selected cells, Delete... with Shift cells up.

If you don't care about the ordering of the numbers (such as an array that will be binned or analyzed with a histogram), then simply copy the row and paste values only in another row. Now just sort the row of values. It will place all the empty cells at the bottom of the selection.

Related

Excel Formula to compare single cell value with the whole column and return the value for a particular row where match found

I need to compare the B2 Cell value (6012469) with Column A i.e. cell A2 to A10 and return the b2 cell value (6012469) in column C where the value matches i.e. cell C5,C7, C9 AND C10 and NA in remaining cells where the value is not matched.
I have around 15000 rows of data is column A and need to automate the process.
I have attached the sample image for reference.
[1]: https://i.stack.imgur.com/DvzC3.png
Select any cell inside your data range in Column A. Go to your ribbon, click Home > Format as Table. It doesn't matter what colour scheme you choose.
Make sure that all your data in Col A plus Cols B & C are included in the table.
Then, in any cell of your table in Col C (e.g. in C2), paste this formula:
=IF(ISNUMBER(SEARCH($B$2,[#[Column A]])),$B$2,"")
Excel should automatically populate all of your Col C in the table with this formula. (If it doesn't, then you should see a little clickable prompt next to the cell asking if you want to overwrite all the other Col C cells with this formula.)
The table with the Col C formulas would look something like this:
Note: Of course, you could achieve something very similar without using a structured table, but not as conveniently as this because you would have to copy the formulas down to the other approx. 15000 rows. Even the Fill Down feature is not as convenient.
ADDITIONAL: a different formula in response to the asker's request that each cell in Column C match any of multiple values in Column B --
=IFERROR(INDEX($B$2:$B$4,MATCH(TRUE,ISNUMBER(SEARCH($B$2:$B$4,A2)),0)),"")
NOTE: if more than one Column B value matches a Column A cell, Column C will display Column B's topmost match

Excel: How do I efficiently condition a cell so that I can identify a cell with observation counts less than a certain number?

Basically I wanted to only extract the top 2 rows for every Entry #, but if the Entry # does not have 2 rows it is not used.
I tried IF statements and eliminating blanks and whatnot, but if this is a large data I would not be able to handle it.
If you don't mind adding a few columns, here's one method. Arrange how you wish.
Column's B and F are your original data.
Column C, in cell C2, input your first value manually (1 in this case).
Then here's the formula for Cell C3:
=IF(ISBLANK(B3),C2,B3)
Cell D2 formula:
=IF(C2=C1,D1+1,1)
Cell E2 formula:
=IF(COUNTIF(C:C,C2)>1,"Yes","No")
Drag down your formulas.
Then you can filter on column E for YES, and filter on column D for 1 & 2.

Combining data in excel

Dears,
I have 4 columns in excel.
Each row have two values but also it is mapped to another row.
I'd like to sum the values from these the rows that are mapped and delete the extra rows.
Example attached: Row A has two values but also mapped to Row C. I want to add the values in Row A with the ones in Row C and keep Row A and delete Row C
Is it possible to use formulas instead of VBA as I don't have experience in VBA?
Please advise.
Assuming your Keyword data starts with A2 and Value 1 starts with B2 and Value 2 starts with C2. (Please refer the snap below)
Apply the below formula in H2 for Value 1 summing and drag down
=IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE))
Apply the below formula in I2 for Value 2 summing and drag down
=IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE))
EDIT #1 If G value does not contain in Table 1 then apply the below formula
in H2
=IF(ISERROR(IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE))),"Not Found in Table",IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE)))
in I2
=IF(ISERROR(IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE))),"Not Found in Table",IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE)))

Excel get cells value if cells contain specific text

I have Table 1 & 2 like image.
How i can get all cells value if ID is equals?
If you just need to add numbers, there are formulas for this, but I'm not sure if there's a single formula for adding string values as in the provided example. One way to resolve this is by using accumulator columns as in this screen shot:
The formula in cell C3 is:
=IF($A3<>C$1,C2,IF(C2=0,$B3,C2&", "&$B3))
Copy this down to cell E10 (or wherever that table needs to end) and columns C to E will accumulate the values from column B. Table 2 then just maps the first and last rows of the accumulator columns. The zeros in cells C2 to E2 is a work-around to prevent Excel from converting blank cells into zeros.
Hope this helps!

Sort row data into columns with same heading in excel 2010

Put simply, I need to sort row data for a specific range into the correct columns based on that columns heading. For example, if there are five columns labelled A through E, and data in the rows below ranging from A through E; I need all of the A's to be in the A column, all of the B's in the B column etc.
Example start data:
How it should look after the sort:
It also must be able to work with the possibility of having empty cells. For example; if the first example data had no B in row 3, the data must not shift over to the left so that C is in the B column etc.
Other info: not feasible to do by hand - over 450 rows.
It also must be able to work with the possibility of having empty cells.
Taking the above into consideration.
NON VBA WAY
Insert enough columns so that the data moves to the right
Next in the row one, duplicate the values from your data
Next in Cell A2 Put this formula
=IF(COUNTIF($H$2:$L$2,A1)>0,A1,"")
Copy the formula to the right
Next remove "$" from the table range and add it to the header in formula in Cell A2 so that we can copy the formula down. This is how it would look
=IF(COUNTIF(H2:L2,$A$1)>0,$A$1,"")
Similarly your B2 formula will look like this
=IF(COUNTIF(H2:L2,$B$1)>0,$B$1,"")
Change it for the rest
How highlight cells A2:E2 and copy the formula down.
Your final Sorted Data looks like this.
Copy columns A:E and do a paste special values on Col A:E itself so that the formulas change into values and then delete Cols H:L

Resources