Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default Change list of cells to paragrph form

Is there a way to change a list of cells to paragraph form in 1 merged cell?
Example:

Blue
Black
Red
Orange
Purple
Green

Convert to:
Blue, Black, Red, Orange, Purple,Green.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Change list of cells to paragrph form

=CONCATENATE(A1,",",A2,",",A3) up to A6

Note: if any blank cells you will get extra commas.

e.g. blue,,red,,orange, green if black and purple are missing.

I prefer using a user defined function like the following which ignores blank
cells.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there.

Save the workbook and hit ALT + Q to return to Excel window.

Enter the formula in a helper cell as =ConCatRange(A1:A6)


Gord Dibben MS Excel MVP

On Thu, 19 Jul 2007 16:56:01 -0700, dford
wrote:

Is there a way to change a list of cells to paragraph form in 1 merged cell?
Example:

Blue
Black
Red
Orange
Purple
Green

Convert to:
Blue, Black, Red, Orange, Purple,Green.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default Change list of cells to paragrph form

That worked great. Thanks for the help.

"Gord Dibben" wrote:

=CONCATENATE(A1,",",A2,",",A3) up to A6

Note: if any blank cells you will get extra commas.

e.g. blue,,red,,orange, green if black and purple are missing.

I prefer using a user defined function like the following which ignores blank
cells.

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

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there.

Save the workbook and hit ALT + Q to return to Excel window.

Enter the formula in a helper cell as =ConCatRange(A1:A6)


Gord Dibben MS Excel MVP

On Thu, 19 Jul 2007 16:56:01 -0700, dford
wrote:

Is there a way to change a list of cells to paragraph form in 1 merged cell?
Example:

Blue
Black
Red
Orange
Purple
Green

Convert to:
Blue, Black, Red, Orange, Purple,Green.



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
How to change data in cells of an existing saved form- Maggie Excel Discussion (Misc queries) 0 October 26th 06 09:40 PM
Can a standard data entry form be used to change formats of cells? BarryW Excel Discussion (Misc queries) 0 January 21st 06 03:06 PM
how can I make a form number change everytime the form is opened babydumplingspita Excel Worksheet Functions 1 October 10th 05 07:58 PM
change info in other cells when i change a number in a drop list? macbr549 Excel Discussion (Misc queries) 2 September 11th 05 02:07 AM
I Need to change reference sheet for all cells on a form Brent E Excel Discussion (Misc queries) 1 February 11th 05 01:36 AM


All times are GMT +1. The time now is 09:42 AM.

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

About Us

"It's about Microsoft Excel"