You are here:

# Excel/macro to convert 2 columns into 1 column

Question
Hi Jan.
I am trying to create a simple macro that converts 2 columns of data into one column of data
e.g.
from
1 A
2 B
3 C
4 D
5 E

to
1
A
2
B
3
C
4
D
5
E
the macro just keeps running until the end of the data in the 2 columns

Hi Tom,

This little macro does the trick:

Sub processData()
Dim lCt As Long
lCt = 1
Do While Cells(lCt, 1).Value <> ""
If Cells(lCt, 2).Value <> "" Then
Cells(lCt + 1, 1).EntireRow.Insert
Cells(lCt + 1, 1).Value = Cells(lCt, 2).Value
Cells(lCt, 2).ClearContents
End If
lCt = lCt + 2
Loop
End Sub
Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment Thanks a lot Jan Karel. That is very much appreciated. Also found out since that the following formula does the same =INDEX(\$A\$1:\$B\$4,INT((ROW()-1)/2)+1,MOD(ROW()-1,2)+1)

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Jan Karel Pieterse

##### Expertise

Excel and Excel/VBA questions

##### Experience

Excel MVP

Organizations
Self employed Excel developer

Education/Credentials
Bachelor in Chemical Engineering

Awards and Honors
Microsoft MVP award since 2002

Past/Present Clients
Shell, Fortis bank, ABN-AMRO bank, Morgan Stanley, ...