Column to text

  • Thread starter Thread starter Niniel
  • Start date Start date
N

Niniel

Hello,

I'm looking for an easy/automated way to take care of the following:
I have single columns of varying size (meaning number of values in the
column) that I need to arrange into a single cell with the values separated
by commas.
E.g.
111
222
333
....
needs to be turned into 111,222,333,...
These columns can contain from 2 to a few hundred values. Obviously, it
would be easy to do this by hand for 2 values, but as the number of values
grows, this becomes tedious and error-prone.
Any suggestions would be greatly appreciated.

Thank you.
 
First select the set of cells you want to process and then run:

Sub merge_them()
Set dest = Application.InputBox(prompt:="click on the destination cell",
Type:=8)
v = ""
For Each r In Selection
v = v & r.Value & ","
Next
dest.Value = Left(v, Len(v) - 1)
End Sub

The macro will ask you to pick the destination cell.
 
Thanks a lot, that works beautifully.
Had to make sure though that
"Set dest = Application.InputBox(prompt:="click on the destination cell",
Type:=8)"
was all in one row, otherwise I got a syntax error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top