Concatenate list of cell values into one cell
Try this:-
Sub stantiate()
Dim myrange As Range
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
Cells(1, 2).Value = Cells(1, 2).Value & c.Value & "|"
Next
End Sub
Works on the active worksheet.
Mike
"bony_tony" wrote:
Hi,
I have a list of data in column A, like the following;
UAD54334
UAD54354
UAD97721
UAD31225
and so on...
I would like to merge all these values into one cell, but with |
seperating each value. ie. I would like cell B2 to display "UAD54334|
UAD54354|UAD97721|UAD31225"
The concatenate function would work fine, but I would have to quote
each cell reference from my list each time.
I'm not sure how to merge data into one cell using VBA.
Some advice would be appreciated.
Thanks
Tony
|