+ Reply to Thread
Results 1 to 2 of 2

Concatenate non-blank values in the same column and add commas

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Concatenate non-blank values in the same column and add commas

    Hi,

    I would like to concatenate all rows in the same column into one string, separated by comma and ignore all the blank cells. The code I have below will concatenate values across columns, but I actually want to concatenate values in the same column. Thanks in advance!

    Chris

    Desired:
    A........B.......C
    1........3........4
    2........5........6
    1,2.....3,4.....4,6

    Code execution give me this:
    A........B.......C
    1........3........4 --> 1,3,4
    2........5........6 --> 2,5,6


    ------------------------------------------------------------
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 06-26-2013 at 08:46 PM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Concatenate non-blank values in the same column and add commas

    Instead of a macro, let's add a new function to your workbook you can use in a cell like any formula.

    Insert this UDF into an emply code module (Insert > Module)
    Please Login or Register  to view this content.
    Close the vbeditor, then use this new function like so:

    =CONCATVALUES(A1:A2, ",")

    Whatever range of cells is in the first parameter will be listed and delimited using the character in the second parameter. You can leave OUT the second parameter and it will use a comma as a default.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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