View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Concatenate list of cell values into one cell

after further reading, I see you want the results in another location. So
the modification would be

Sub ABCD()
Dim rng As Range, cell1 As Range
Dim cell As Range
Set rng = Selection
Set cell1 = Range("B2")
cell1.clearcontents
For Each cell In rng
cell1.Value = cell1 & "|" & cell
Next
End Sub

--
Regards,
Tom Ogilvy


"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