Saturday, 7 September 2019

microsoft excel - Stack Ranges into 1 Column


If I had two columns by 4 rows:


A1 B1 A2 B2 A3 B3 A4 B4


I would like the result


A1 A2 A3 A4 B1 B2 B3 B4


I've used choose function to combine different ranges before ... but it doesn't seem to like stacking things into one array. I.e =CHOOSE({1;2},A1:A4,B1:B4)


In google sheets you can simply ={A1:A4;B1:B4} To achieve the same result. How do I do this in excel without VBA?



Answer



Pick a cell, enter:


=OFFSET($A$1,MOD(ROWS($1:1)-1,4),ROUNDUP(ROWS($1:1)/4,0)-1)

and copy down:


enter image description here


Note:


Using similar formulas, you can map any 2-D table into a single column or a single row in either row order or column order.


EDIT#1:


To avoid copy/paste, first select the block of eight cells from C5 through C12, then click in the formula bar and type the formula, and enter it using Cntrl+Enter rather than just the Enter key.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...