Concatenate range of rows

AnilPullagura

Board Regular
Joined
Nov 19, 2010
Messages
98
Hey Pros,

I was just thinking if this forum can help me out in solving my issue:

I have around 2000 rows of data in the range A2:A2001. Each cell(A1) has only 12 characters(alphanumerice) such as 11241F021500. I was trying to Concatenate all these cells to a single cell, say "G1".

Also i want these values to be seperated by a comma ",". I would prefer a macro which i can run for the above range.

I searched forums and found only UDF's, but i want to have it in a macro.
Also, the range is subject to change, it might NOT always be 2000, could be less or more.

Any help on this is greatly appreciated.

EXCEL 2010

Thanks,
Anil Pullagura
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try:
Code:
Sub Con()
lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("G2").ClearContents
For i = 2 To lr
    If IsEmpty(Range("G2")) Then
        Range("G2").Value = Range("A" & i)
    Else
        Range("G2").Value = Range("G2") & "," & Range("A" & i)
    End If
Next
End Sub
 
Upvote 0
Here is another way.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> Con2()<br>    Range("G2").Value = Join(Application.Transpose(Range("A2", Range("A" & Rows.Count).End(xlUp)).Value), ",")<br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top