PC Review


Reply
Thread Tools Rate Thread

Concatenating cells but excluding blanks

 
 
Bob Freeman
Guest
Posts: n/a
 
      12th Jan 2010
Hello,

I am trying to create a result field, concatenating populated cells from the
previous 12 columns on that line, but excluding blank cells and putting a *
delimiting character between each instance - please find below a 4 column
example.

ID 1 2 3 4 Result
Z A C D A*C*D
Y B C B*C
X A B D A*B*D

Each of the 10,000 lines of the spreadsheet is different - there are at
least 5 blank cells on each line

Any help gratefully received. I am working in Excel 2007

Many thanks.

Bob
 
Reply With Quote
 
 
 
 
מיכאל (מיקי) אבידן
Guest
Posts: n/a
 
      12th Jan 2010
Try this:
http://img690.imageshack.us/img690/5826/nonamee.png
Micky


"Bob Freeman" wrote:

> Hello,
>
> I am trying to create a result field, concatenating populated cells from the
> previous 12 columns on that line, but excluding blank cells and putting a *
> delimiting character between each instance - please find below a 4 column
> example.
>
> ID 1 2 3 4 Result
> Z A C D A*C*D
> Y B C B*C
> X A B D A*B*D
>
> Each of the 10,000 lines of the spreadsheet is different - there are at
> least 5 blank cells on each line
>
> Any help gratefully received. I am working in Excel 2007
>
> Many thanks.
>
> Bob

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      12th Jan 2010
This UDF will concatenate a range and exclude blanks.

Function ConCatRange(CellBlock As Range) As String
'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 & "*"
Next
ConCatRange = Left(sbuf, Len(sbuf) - 2)
End Function

=concatrange(range)


Gord Dibben MS Excel MVP

On Tue, 12 Jan 2010 05:23:01 -0800, Bob Freeman
<(E-Mail Removed)> wrote:

>Hello,
>
>I am trying to create a result field, concatenating populated cells from the
>previous 12 columns on that line, but excluding blank cells and putting a *
>delimiting character between each instance - please find below a 4 column
>example.
>
>ID 1 2 3 4 Result
>Z A C D A*C*D
>Y B C B*C
>X A B D A*B*D
>
>Each of the 10,000 lines of the spreadsheet is different - there are at
>least 5 blank cells on each line
>
>Any help gratefully received. I am working in Excel 2007
>
>Many thanks.
>
>Bob


 
Reply With Quote
 
מיכאל (מיקי) אבידן
Guest
Posts: n/a
 
      13th Jan 2010
I assume you meant:
ConCatRange = Left(sbuf, Len(sbuf) - 1)
Micky


"Gord Dibben" wrote:

> This UDF will concatenate a range and exclude blanks.
>
> Function ConCatRange(CellBlock As Range) As String
> '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 & "*"
> Next
> ConCatRange = Left(sbuf, Len(sbuf) - 2)
> End Function
>
> =concatrange(range)
>
>
> Gord Dibben MS Excel MVP
>
> On Tue, 12 Jan 2010 05:23:01 -0800, Bob Freeman
> <(E-Mail Removed)> wrote:
>
> >Hello,
> >
> >I am trying to create a result field, concatenating populated cells from the
> >previous 12 columns on that line, but excluding blank cells and putting a *
> >delimiting character between each instance - please find below a 4 column
> >example.
> >
> >ID 1 2 3 4 Result
> >Z A C D A*C*D
> >Y B C B*C
> >X A B D A*B*D
> >
> >Each of the 10,000 lines of the spreadsheet is different - there are at
> >least 5 blank cells on each line
> >
> >Any help gratefully received. I am working in Excel 2007
> >
> >Many thanks.
> >
> >Bob

>
> .
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      13th Jan 2010
I meant ConCatRange = Left(sbuf, Len(sbuf) - 2)

Try it using ConCatRange = Left(sbuf, Len(sbuf) - 1)

See the difference?


Gord

On Wed, 13 Jan 2010 00:21:01 -0800, ????? (????) ?????
<micky-a*at*tapuz.co.il> wrote:

>I assume you meant:
>
>Micky
>
>
>"Gord Dibben" wrote:
>
>> This UDF will concatenate a range and exclude blanks.
>>
>> Function ConCatRange(CellBlock As Range) As String
>> '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 & "*"
>> Next
>> ConCatRange = Left(sbuf, Len(sbuf) - 2)
>> End Function
>>
>> =concatrange(range)
>>
>>
>> Gord Dibben MS Excel MVP
>>
>> On Tue, 12 Jan 2010 05:23:01 -0800, Bob Freeman
>> <(E-Mail Removed)> wrote:
>>
>> >Hello,
>> >
>> >I am trying to create a result field, concatenating populated cells from the
>> >previous 12 columns on that line, but excluding blank cells and putting a *
>> >delimiting character between each instance - please find below a 4 column
>> >example.
>> >
>> >ID 1 2 3 4 Result
>> >Z A C D A*C*D
>> >Y B C B*C
>> >X A B D A*B*D
>> >
>> >Each of the 10,000 lines of the spreadsheet is different - there are at
>> >least 5 blank cells on each line
>> >
>> >Any help gratefully received. I am working in Excel 2007
>> >
>> >Many thanks.
>> >
>> >Bob

>>
>> .
>>


 
Reply With Quote
 
Katherine Berchtold
Guest
Posts: n/a
 
      15th Sep 2010
Hi Gord,

I used the macro you posted to concatenate a range of data and exclude the blanks.

This works great, the only problem is that it cuts off the last letter of the last word.

Please help!

Thank you.

Katherine

> On Tuesday, January 12, 2010 8:23 AM Bob Freeman wrote:


> Hello,
>
> I am trying to create a result field, concatenating populated cells from the
> previous 12 columns on that line, but excluding blank cells and putting a *
> delimiting character between each instance - please find below a 4 column
> example.
>
> ID 1 2 3 4 Result
> Z A C D A*C*D
> Y B C B*C
> X A B D A*B*D
>
> Each of the 10,000 lines of the spreadsheet is different - there are at
> least 5 blank cells on each line
>
> Any help gratefully received. I am working in Excel 2007
>
> Many thanks.
>
> Bob



>> On Tuesday, January 12, 2010 3:33 PM ????? (????) ????? wrote:


>> Try this:
>> http://img690.imageshack.us/img690/5826/nonamee.png
>> Micky
>>
>>
>> "Bob Freeman" wrote:



>>> On Tuesday, January 12, 2010 5:26 PM Gord Dibben wrote:


>>> This UDF will concatenate a range and exclude blanks.
>>>
>>> Function ConCatRange(CellBlock As Range) As String
>>> '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 & "*"
>>> Next
>>> ConCatRange = Left(sbuf, Len(sbuf) - 2)
>>> End Function
>>>
>>> =concatrange(range)
>>>
>>>
>>> Gord Dibben MS Excel MVP



>>>> On Wednesday, January 13, 2010 3:21 AM ????? (????) ????? wrote:


>>>> I assume you meant:
>>>> ConCatRange = Left(sbuf, Len(sbuf) - 1)
>>>> Micky
>>>>
>>>>
>>>> "Gord Dibben" wrote:



>>>>> On Wednesday, January 13, 2010 12:43 PM Gord Dibben wrote:


>>>>> I meant ConCatRange = Left(sbuf, Len(sbuf) - 2)
>>>>>
>>>>> Try it using ConCatRange = Left(sbuf, Len(sbuf) - 1)
>>>>>
>>>>> See the difference?
>>>>>
>>>>>
>>>>> Gord
>>>>>
>>>>> <micky-a*at*tapuz.co.il> wrote:



>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>> Silverlight Custom ValidationSummary with Data Form
>>>>> http://www.eggheadcafe.com/tutorials...data-form.aspx

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      17th Sep 2010
Micky was correct..............change the -2 to -1 in this case.


Gord

On Wed, 15 Sep 2010 13:43:40 GMT, Katherine Berchtold
<(E-Mail Removed)> wrote:

>Hi Gord,
>
>I used the macro you posted to concatenate a range of data and exclude the blanks.
>
>This works great, the only problem is that it cuts off the last letter of the last word.
>
>Please help!
>
>Thank you.
>
>Katherine
>
>> On Tuesday, January 12, 2010 8:23 AM Bob Freeman wrote:

>
>> Hello,
>>
>> I am trying to create a result field, concatenating populated cells from the
>> previous 12 columns on that line, but excluding blank cells and putting a *
>> delimiting character between each instance - please find below a 4 column
>> example.
>>
>> ID 1 2 3 4 Result
>> Z A C D A*C*D
>> Y B C B*C
>> X A B D A*B*D
>>
>> Each of the 10,000 lines of the spreadsheet is different - there are at
>> least 5 blank cells on each line
>>
>> Any help gratefully received. I am working in Excel 2007
>>
>> Many thanks.
>>
>> Bob

>
>
>>> On Tuesday, January 12, 2010 3:33 PM ????? (????) ????? wrote:

>
>>> Try this:
>>> http://img690.imageshack.us/img690/5826/nonamee.png
>>> Micky
>>>
>>>
>>> "Bob Freeman" wrote:

>
>
>>>> On Tuesday, January 12, 2010 5:26 PM Gord Dibben wrote:

>
>>>> This UDF will concatenate a range and exclude blanks.
>>>>
>>>> Function ConCatRange(CellBlock As Range) As String
>>>> '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 & "*"
>>>> Next
>>>> ConCatRange = Left(sbuf, Len(sbuf) - 2)
>>>> End Function
>>>>
>>>> =concatrange(range)
>>>>
>>>>
>>>> Gord Dibben MS Excel MVP

>
>
>>>>> On Wednesday, January 13, 2010 3:21 AM ????? (????) ????? wrote:

>
>>>>> I assume you meant:
>>>>> ConCatRange = Left(sbuf, Len(sbuf) - 1)
>>>>> Micky
>>>>>
>>>>>
>>>>> "Gord Dibben" wrote:

>
>
>>>>>> On Wednesday, January 13, 2010 12:43 PM Gord Dibben wrote:

>
>>>>>> I meant ConCatRange = Left(sbuf, Len(sbuf) - 2)
>>>>>>
>>>>>> Try it using ConCatRange = Left(sbuf, Len(sbuf) - 1)
>>>>>>
>>>>>> See the difference?
>>>>>>
>>>>>>
>>>>>> Gord
>>>>>>
>>>>>> <micky-a*at*tapuz.co.il> wrote:

>
>
>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>>> Silverlight Custom ValidationSummary with Data Form
>>>>>> http://www.eggheadcafe.com/tutorials...data-form.aspx

 
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
Concatenating adjacent cells ignoring blanks and adding a delimite Bob Freeman Microsoft Excel Misc 3 27th Jan 2010 09:14 PM
Dsum excluding blanks Michelle Microsoft Excel Worksheet Functions 1 19th Dec 2009 12:01 PM
How can I ignore blanks when concatenating cells in Excel? =?Utf-8?B?TmF0Q2hhdA==?= Microsoft Excel Misc 5 26th Feb 2007 05:01 AM
How to get lowest value excluding blanks =?Utf-8?B?Sm9oblQ=?= Microsoft Excel Worksheet Functions 5 4th Dec 2004 10:57 AM
excluding the blanks flomo Microsoft Excel Worksheet Functions 2 16th Jun 2004 11:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:21 AM.