tehaaron
tehaaron

Reputation: 2250

Excel - Skip Blank Table Cells Formula

I have a table being created via an XML map so it has a lot of blank cells in each column. It looks like:

| Name | Stat 1 | Stat 2 | Stat 3|
| Test |        |        |       |
|      |  Four  |        |       |
|      |        |   5    |       |
|      |        |        |  102  |

Basically each row has only one value and I am trying to transpose it onto another worksheet where all the values are one row like this:

| Name | Stat 1 | Stat 2 | Stat 3 |
| Test |   Four |    5   |   102  |

In my searching I found this formula:

=IFERROR(INDEX(Table9[@name],SMALL(IF(Table9[@name]<>"",ROW(Table9[@name])-ROW(Table9[@name])+1),ROWS(A2))),"")

I set that and in A1 of another sheet and drag it down and it does return the populated cells but it is also returning 0 for all the blank cells instead of skipping them until it has a value to return.

There may be a better way to do this so I am open to other options but would prefer to avoid vba if possible.

Thanks.

Upvotes: 1

Views: 1180

Answers (1)

Aprillion
Aprillion

Reputation: 22322

Let's say input sheet is called Sheet1 and the Name is in cell A1 on both sheets. Then use following formula for Name on output sheet:

=INDEX(Sheet1!A:A,(ROW()-2)*4+2)

and for Stat 1:

=INDEX(Sheet1!B:B,(ROW()-2)*4+3)

and so on ... more generally:

=INDEX(
  input_column_range,
  (ROW()-first_row_in_output)*number_of_columns + first_row_in_input+column_index
)

Upvotes: 0

Related Questions