Frage

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!

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top