Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Combining cells with separater

Hello!

I am needing to combine a row of cells into one cell. Say, for example,
A1:A500 are all zip codes. How can I combine all the 500 zip codes into one
cell, separated by a semicolon?

Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Combining cells with separater

Not sure why you would need to do this.

But...........This UDF will do it for you.

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

Note: you most likely will not see all the characters displayed in the cell
due to Excel's 1024 character display limit.

However, the data will all be seen in the formula bar.

=ConCatRange(A1:A500)

To increase the 1024 limit, paste the formula results as values then
manually add and Alt + Enter linefeed every 100 or so characters.


Gord Dibben MS Excel MVP

On Thu, 21 Jan 2010 13:31:15 -0800, Lisa L <Lisa
wrote:

Hello!

I am needing to combine a row of cells into one cell. Say, for example,
A1:A500 are all zip codes. How can I combine all the 500 zip codes into one
cell, separated by a semicolon?

Thank you!


  #3   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Combining cells with separater

A little tinker to try ..
Copy A1:A500, paste into Notepad
Copy from Notepad, paste into formula bar for B1
Put in C1: =SUBSTITUTE(B1,CHAR(10),";")
Copy C1, paste into Notepad. Done in 10 sec
Success? celebrate it, hit the YES below
--
Max
Singapore
---
"Lisa L" wrote:
I am needing to combine a row of cells into one cell. Say, for example,
A1:A500 are all zip codes. How can I combine all the 500 zip codes into one
cell, separated by a semicolon?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Combining cells with separater

This works great! Thank you for your assistance! Happy Friday!

"Max" wrote:

A little tinker to try ..
Copy A1:A500, paste into Notepad
Copy from Notepad, paste into formula bar for B1
Put in C1: =SUBSTITUTE(B1,CHAR(10),";")
Copy C1, paste into Notepad. Done in 10 sec
Success? celebrate it, hit the YES below
--
Max
Singapore
---
"Lisa L" wrote:
I am needing to combine a row of cells into one cell. Say, for example,
A1:A500 are all zip codes. How can I combine all the 500 zip codes into one
cell, separated by a semicolon?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Combining cells with separater

Max's response above worked for me. I do appreciate your response though!
PS...the reason I needed to do this is because I have to paste the zip codes
with a semi colon between each one, into a different program. I was hoping
not to have to type them! Happy Friday!

"Gord Dibben" wrote:

Not sure why you would need to do this.

But...........This UDF will do it for you.

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

Note: you most likely will not see all the characters displayed in the cell
due to Excel's 1024 character display limit.

However, the data will all be seen in the formula bar.

=ConCatRange(A1:A500)

To increase the 1024 limit, paste the formula results as values then
manually add and Alt + Enter linefeed every 100 or so characters.


Gord Dibben MS Excel MVP

On Thu, 21 Jan 2010 13:31:15 -0800, Lisa L <Lisa
wrote:

Hello!

I am needing to combine a row of cells into one cell. Say, for example,
A1:A500 are all zip codes. How can I combine all the 500 zip codes into one
cell, separated by a semicolon?

Thank you!


.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 806
Default Combining cells with separater

Hello Gord,

...
Note: *you most likely will not see all the characters displayed in the cell
due to Excel's 1024 character display limit.
...


1024 characters?

http://www.xlam.ch/xlimits/ shows [Zeichen = characters] per cell:

Excel 2.x: 255 Zeichen
Excel 3.0: 255 Zeichen
Excel 4.0: 255 Zeichen
Excel 5.0: 255 Zeichen
Excel 7.0/95: 255 Zeichen
Excel 97: 32'000 Zeichen = 32'767 Zeichen
Excel 2000: 32'767 Zeichen
Excel 2002: 32'767 Zeichen
Excel 2003: 32'767 Zeichen
Excel 2007: 32'767 Zeichen

Regards,
Bernd
  #7   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Combining cells with separater

Welcome, Lisa. Glad to hear. Think you forgot to hit the YES below in that
earlier response ..
--
Max
Singapore
---
"Lisa L" wrote:
This works great! Thank you for your assistance! Happy Friday!


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
Combining Cells Fredgus Excel Discussion (Misc queries) 3 December 18th 08 07:23 PM
Need help with combining cells to one Coolquicc Excel Discussion (Misc queries) 3 September 10th 08 11:08 PM
Combining 2 cells Steved Excel Worksheet Functions 2 July 26th 06 08:02 AM
combining cells Mindy Excel Worksheet Functions 1 January 9th 06 09:16 PM
combining cells lyneday Excel Discussion (Misc queries) 2 December 3rd 04 05:45 PM


All times are GMT +1. The time now is 09:06 PM.

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"