Kuba Guzik
Kuba Guzik

Reputation: 23

Combining 2 columns into 1. (one after the other)

I would like to combine 2 columns into 1. One after the other.

I have this:

       A  B
Row 1: 1  10
Row 2: 2  11
Row 3: 3  12
Row 4: 4  13

And would like to obtain this:

       A
Row 1: 1
Row 2: 2
Row 3: 3
Row 4: 4
Row 5: 10
Row 6: 11
Row 7: 12
Row 8: 13

The number of rows in the 2 columns is different every time (number of rows in A and B is the same).

I tried many functions and I'm close but still not there. Would appreciate any help. I prefer formulas. I'm still a newbie in VBA but any help would be fine.

Thanks!

Upvotes: 2

Views: 427

Answers (2)

Scott Craner
Scott Craner

Reputation: 152450

Here is a formula that will do it.

Put it in C1 and copy down.

=IF(A1<>"",A1,INDEX(B:B,ROW()-COUNTA(A:A)))

enter image description here

Upvotes: 2

sn152
sn152

Reputation: 276

Try this.

Range("B1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlToLeft).Select
Selection.End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste
Range("A1").Select

Upvotes: -1

Related Questions