ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Concatenate Macro (https://www.excelbanter.com/excel-programming/380565-concatenate-macro.html)

Dan R.

Concatenate Macro
 
I have a list of values in Column A. In Column B - Row 1 I want to
concatenate the values from Column A - Rows 1-50 with commas in between
each value, and in Column B - Row 2 I want to concatenate the values
from rows 51-100 with commas in between. I'm using a ridiculously long
formula right now to do this.... =A1&","&A2&","&A3&","&A4&","&A5....
and on and on and on...

Can someone please help me write a macro to do this?

Thanks
- Dan


Dan R.

Concatenate Macro
 
Thanks a lot, that's exactly what I needed.

- Dan

Gary''s Student wrote:
Here is a simple function that concatentates a range of cells:

Function mergem(r As Range) As String
mergem = r.Cells(1, 1).Value
k = 1
For Each rr In r
If k < 1 Then
mergem = mergem & "," & rr.Value
End If
k = 2
Next
End Function
--
Gary's Student


"Dan R." wrote:

I have a list of values in Column A. In Column B - Row 1 I want to
concatenate the values from Column A - Rows 1-50 with commas in between
each value, and in Column B - Row 2 I want to concatenate the values
from rows 51-100 with commas in between. I'm using a ridiculously long
formula right now to do this.... =A1&","&A2&","&A3&","&A4&","&A5....
and on and on and on...

Can someone please help me write a macro to do this?

Thanks
- Dan





All times are GMT +1. The time now is 03:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com