MalusPuer
MalusPuer

Reputation: 31

Merging Columns in Excel

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

Answers (3)

Sergio
Sergio

Reputation: 503

=A1&","&B1 would also work

Upvotes: 0

Jeff Anderson
Jeff Anderson

Reputation: 819

Here is an excel formula

=CONCATENATE(A1,",", B1)

Upvotes: 1

Tom
Tom

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

Related Questions