PC Review


Reply
Thread Tools Rate Thread

Concatenate contiguous fields on one worksheet into 1 field on ano

 
 
MargeB
Guest
Posts: n/a
 
      5th Oct 2009
I have an Excel workbook that has 2 worksheets. One worksheet (called Master)
has company and address information in separate, contiguous cells. I need to
concatenate those cells into a single cell on the other worksheet, with line
breaks between.

Example:
Company Name
Address Line 1
Address Line 2
City, ST Zipcode

Some addresses will not have the Address Line 2, and I don't want to show a
blank line.

Thanks
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      5th Oct 2009
Function ConCatRange(CellBlock As Range) As String
'ignores blank cells
'for non-contiguous cells =ccr((a1:a10,c4,c6,e1:e5))
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.Text) > 0 Then sbuf = sbuf & Cell.Text & vbLf
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

=concatrange(Master!A1:A4)


Gord Dibben MS Excel MVP

On Mon, 5 Oct 2009 14:30:01 -0700, MargeB <(E-Mail Removed)>
wrote:

>I have an Excel workbook that has 2 worksheets. One worksheet (called Master)
>has company and address information in separate, contiguous cells. I need to
>concatenate those cells into a single cell on the other worksheet, with line
>breaks between.
>
>Example:
>Company Name
>Address Line 1
>Address Line 2
>City, ST Zipcode
>
>Some addresses will not have the Address Line 2, and I don't want to show a
>blank line.
>
>Thanks


 
Reply With Quote
 
MargeB
Guest
Posts: n/a
 
      13th Oct 2009
Thanks for the reply. I haven't had a chance to try it yet.

"Gord Dibben" wrote:

> Function ConCatRange(CellBlock As Range) As String
> 'ignores blank cells
> 'for non-contiguous cells =ccr((a1:a10,c4,c6,e1:e5))
> Dim Cell As Range
> Dim sbuf As String
> For Each Cell In CellBlock
> If Len(Cell.Text) > 0 Then sbuf = sbuf & Cell.Text & vbLf
> Next
> ConCatRange = Left(sbuf, Len(sbuf) - 1)
> End Function
>
> =concatrange(Master!A1:A4)
>
>
> Gord Dibben MS Excel MVP
>
> On Mon, 5 Oct 2009 14:30:01 -0700, MargeB <(E-Mail Removed)>
> wrote:
>
> >I have an Excel workbook that has 2 worksheets. One worksheet (called Master)
> >has company and address information in separate, contiguous cells. I need to
> >concatenate those cells into a single cell on the other worksheet, with line
> >breaks between.
> >
> >Example:
> >Company Name
> >Address Line 1
> >Address Line 2
> >City, ST Zipcode
> >
> >Some addresses will not have the Address Line 2, and I don't want to show a
> >blank line.
> >
> >Thanks

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate Text Fields to Date Field alhotch Microsoft Access Queries 5 19th May 2010 06:43 PM
How can I concatenate 2 FIELDS IN A NEW FIELD IN A TABLE =?Utf-8?B?bWlsdG9u?= Microsoft Access 12 12th Aug 2006 05:13 PM
Concatenate two fields (text & number) for key field Larry Elfenbein Microsoft Access Forms 2 10th Nov 2005 01:23 PM
concatenate a number of fields into a memo field =?Utf-8?B?YmljeWNsb3Bz?= Microsoft Access VBA Modules 3 6th May 2005 04:12 AM
Concatenate four separate fields into one field Bob Corcoran Microsoft Access Getting Started 2 23rd Nov 2003 11:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:23 AM.