Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default convert column to a cell with formatting

I am trying to figure out the best way to convert the following:
1
2
3

To (in a single cell):
1,2,3

I'm guessing a function? The list is variable, meaning it could have any
number of rows up to about 50 or so.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default convert column to a cell with formatting

If you can live with a helper column then enter this in B1
=A1
and this in B2 and copy down
=B1&IF(A2="","",","&A2)

Last cell will contain what you want
You can have a cell at top =B1000 or soemthing to get it at top (1000 being
much more that your last col and copy formula down to 1000)
"OnTheEdge" wrote:

I am trying to figure out the best way to convert the following:
1
2
3

To (in a single cell):
1,2,3

I'm guessing a function? The list is variable, meaning it could have any
number of rows up to about 50 or so.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default convert column to a cell with formatting

Try the following UDF:

Function mergum(r As Range) As String
mergum = ""
oneshot = 1
For Each cell In r
If oneshot = 1 Then
mergum = cell.Value
oneshot = 0
Else
mergum = mergum & "," & cell.Value
End If
Next
End Function

--
Gary''s Student - gsnu200810


"OnTheEdge" wrote:

I am trying to figure out the best way to convert the following:
1
2
3

To (in a single cell):
1,2,3

I'm guessing a function? The list is variable, meaning it could have any
number of rows up to about 50 or so.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default convert column to a cell with formatting

Or this one which ignores blank cells if any are present in the range.

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) - 1)
End Function

=concatrange(range)


Gord Dibben MS Excel MVP


On Tue, 28 Oct 2008 12:28:10 -0700, Gary''s Student
wrote:

Try the following UDF:

Function mergum(r As Range) As String
mergum = ""
oneshot = 1
For Each cell In r
If oneshot = 1 Then
mergum = cell.Value
oneshot = 0
Else
mergum = mergum & "," & cell.Value
End If
Next
End Function


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formatting to every cell in a column Paul Kraemer Excel Discussion (Misc queries) 7 June 10th 07 11:56 PM
Conditional formatting when cell value is top 3 of column . . . Hubitron2000 Excel Discussion (Misc queries) 3 March 21st 06 09:39 PM
BULK Conditional Formatting - by column without going into each cell? Rob Moyle Excel Discussion (Misc queries) 2 January 13th 06 06:51 PM
Conditional formatting row if cell value in certain column is even Hyland Hunt Excel Worksheet Functions 1 February 2nd 05 08:21 PM
How do I convert the result of LARGE to the cell (or column) refe. Liam Judd Excel Worksheet Functions 1 November 17th 04 08:44 AM


All times are GMT +1. The time now is 03:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"