PC Review


Reply
Thread Tools Rate Thread

concatenate formula for rows with differing amount of columns

 
 
tommykraz
Guest
Posts: n/a
 
      18th Jun 2008
Hi,
I need some help writing a formula that will concatenate columns by rows but
where the number of columns to be concatenated differs between the rows. I
also need to place comma delimiters between each value.

For Example
Row1: 345 3432 5631 76523 342
Row2: 87 234 546

My results need to show:
Row1: 345,3432,5631,76523,342
Row2: 87,234,546

This sounds easy, but I need Row2 to avoid showing the last two commas:
87,234,546,,

Thanks for the help!

 
Reply With Quote
 
 
 
 
excelent
Guest
Posts: n/a
 
      18th Jun 2008
=SUBSTITUTE(A1&","&B1&","&C1&","&D1&","&E1,REPT(",",5-COUNTA(A1:E1)),"")


"tommykraz" skrev:

> Hi,
> I need some help writing a formula that will concatenate columns by rows but
> where the number of columns to be concatenated differs between the rows. I
> also need to place comma delimiters between each value.
>
> For Example
> Row1: 345 3432 5631 76523 342
> Row2: 87 234 546
>
> My results need to show:
> Row1: 345,3432,5631,76523,342
> Row2: 87,234,546
>
> This sounds easy, but I need Row2 to avoid showing the last two commas:
> 87,234,546,,
>
> Thanks for the help!
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      18th Jun 2008
This UDF will ignore 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

=ConCatRange(select cells)


Gord Dibben MS Excel MVP

On Wed, 18 Jun 2008 11:20:02 -0700, tommykraz
<(E-Mail Removed)> wrote:

>Hi,
>I need some help writing a formula that will concatenate columns by rows but
>where the number of columns to be concatenated differs between the rows. I
>also need to place comma delimiters between each value.
>
>For Example
>Row1: 345 3432 5631 76523 342
>Row2: 87 234 546
>
>My results need to show:
>Row1: 345,3432,5631,76523,342
>Row2: 87,234,546
>
>This sounds easy, but I need Row2 to avoid showing the last two commas:
>87,234,546,,
>
>Thanks for the help!


 
Reply With Quote
 
tommykraz
Guest
Posts: n/a
 
      18th Jun 2008
Thanks a million...helped a lot.

"excelent" wrote:

> =SUBSTITUTE(A1&","&B1&","&C1&","&D1&","&E1,REPT(",",5-COUNTA(A1:E1)),"")
>
>
> "tommykraz" skrev:
>
> > Hi,
> > I need some help writing a formula that will concatenate columns by rows but
> > where the number of columns to be concatenated differs between the rows. I
> > also need to place comma delimiters between each value.
> >
> > For Example
> > Row1: 345 3432 5631 76523 342
> > Row2: 87 234 546
> >
> > My results need to show:
> > Row1: 345,3432,5631,76523,342
> > Row2: 87,234,546
> >
> > This sounds easy, but I need Row2 to avoid showing the last two commas:
> > 87,234,546,,
> >
> > Thanks for the help!
> >

 
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
IF formula for differing text within two separate columns Colin Hayes Microsoft Excel Worksheet Functions 4 17th Dec 2010 02:28 PM
RE: Concatenate info from columns into rows jbjtc Microsoft Excel Misc 2 7th Dec 2007 02:57 PM
Concatenate multiple rows and columns into 1 cell =?Utf-8?B?bWo0NA==?= Microsoft Excel Misc 21 19th Jul 2007 09:18 AM
Compare and align rows of multiple but differing columns of data e abor Microsoft Excel Discussion 0 6th Jun 2006 05:04 PM
Compare and align rows of multiple but differing columns of data e abor Microsoft Excel Discussion 0 6th Jun 2006 05:04 PM


Features
 

Advertising
 

Newsgroups
 


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