Home » excel » Excel move even cells to separate column

Excel move even cells to separate column

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have been given a spreadsheet that has a single column with odd numbered rows containing a value and even numbered rows containing an associated date. I would like to convert this into a format where the odd row values have their assocated date in the same row but a separate column, e.g.

|ABC1234  |     |ABC1234|13-Dec-13|
|---------|     |-------|---------|
|13-Dec-13|     |ABC1235|14-Dec-13|
|---------|     |-------|---------|
|ABC1235  |     |ABC1236|15-Dec-13|
|---------| -> 
|14-Dec-13|
|---------|
|ABC1236  |
|---------|
|15-Dec-13|

Is this possible just using the formulas or would a macro be required?

How to&Answers:

This feels like a hack, but assuming you start at the top of the excel doc, you can use this formula:

    =INDIRECT("A" & (2*ROW()))

Where “A” is the column name of the original data (the column with the alternating data types). INDIRECT basically concatenates “A” with the value of 2*ROW(). And, ROW() gives the current row number of the cell. If you need to offset it due to headers or something like that, you can add or subtract an offset after 2*ROW() (in order to change the row number).

So, you would use

    =INDIRECT("A" & (2*ROW()-1))

to make the ABC…. column and then use

    =INDIRECT("A" & (2*ROW()))

to make the date column