Reputation: 31
I have an excel sheet with two columns A and B. I need to merge these columns and have the result be separated by commas. For example:
Column A | Column B
1 2
Would become
Column C
1,2
If possible I would like this to be done with VBA or an excel formula executed by VBA.
Upvotes: 0
Views: 154
Reputation: 9878
This will take an initial range (defined as rng) cycle through all the rows in this range outputting the contents of column A and B in that row to column C in the same row.
set rng = Range(cells(1,1), cells(activesheet.UsedRange.Rows,1))
for each cell in rng
cell.offset(0,2) = cell & "," & cell.offset(0,1)
next cell
Upvotes: 1