Concatenate Cells
Ryan
Just a head's up.
In cases where there are any blank cells in the range, your code will add
extra commas.
This revision will ignore blank cells.
Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) 0 Then sbuf = sbuf & Cell.text & ","
Next
ConCatRange = Left(sbuf, Len(sbuf) - 2)
End Function
Gord Dibben MS Excel MVP
On Tue, 15 Dec 2009 14:59:02 -0800, ryguy7272
wrote:
Maybe this is what you want?
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
With your data in cells A1:E1, =mergem(A1:E1)
|