ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Column to text (https://www.excelbanter.com/excel-discussion-misc-queries/195246-column-text.html)

Niniel

Column to text
 
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.

Gary''s Student

Column to text
 
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.
--
Gary''s Student - gsnu200795


"Niniel" wrote:

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.


Niniel

Column to text
 
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.




All times are GMT +1. The time now is 08:02 PM.

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