+ Reply to Thread
Results 1 to 7 of 7

Concatenate non blanks and add commas

  1. #1
    Registered User
    Join Date
    08-20-2007
    Posts
    10

    Concatenate non blanks and add commas

    Hi,

    How would I concatenate a large range of cells, most of which are blank, and add a comma between each cell's value?
    My range is E2:Y2 (I will be filling down), but most of the cells are blank. For example, if I F2=9, I2=11 and X=25, I would like to display them as: 9,11,25.
    If in the next row, G=10, K=15 and Y=27, they should look like this: 10,15,27.

    Thanks in advance!

    Jenny
    Last edited by jennyp6606; 04-30-2009 at 04:09 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,905

    Re: Concatenate non blanks and add commas

    Not easily done with native excel... unless you like a long formula...

    i.e. =TRIM(E2&",",&F2&",",&G2&","& etc... &Y2)

    You can download and install a free addin from here callled Morefunc.xll

    and then use formula:

    =MCONCAT(E2:Y2,",")
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    04-28-2009
    Location
    Chicago, IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Concatenate non blanks and add commas

    The big-but-readable solution:

    Please Login or Register  to view this content.
    Note that this writes the result into the first column of the sheet, so figure out a better solution for output if you need to preserver the first column.

    Also note that I made assumptions about the ranges involved.

  4. #4
    Registered User
    Join Date
    08-20-2007
    Posts
    10

    Re: Concatenate non blanks and add commas

    That worked beautifully. Thanks!!

  5. #5
    Registered User
    Join Date
    10-19-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Concatenate non blanks and add commas

    Thank you. I have used this thread to download the morefunc.xll to use the MCONCAT function. My issue is how do you eliminate the seperator when there are no values, or only one value? I only want the separator when there are multiple values.

    Thanks.

  6. #6
    Administrator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,143

    Re: Concatenate non blanks and add commas

    golfpromal,

    This is a 3 yr old thread and not likely to get any viewers. Why not open a new thread?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Registered User
    Join Date
    10-19-2012
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Concatenate non blanks and add commas

    Thank you/

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1