+ Reply to Thread
Results 1 to 4 of 4

formula to concatenate cells with data

  1. #1
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    formula to concatenate cells with data

    Hi,

    Is there a way to nest IF & And statements. I'm looking to concatenate a number of cells and seperate them with a space and/or comma but only if they contain data so need something along the lines of
    Please Login or Register  to view this content.
    I know I can do this with VBA was looking for a non VBA solution
    Last edited by tryer; 02-06-2009 at 05:44 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: formula to concatenate cells with data

    Do you mean something along the lines of:

    Please Login or Register  to view this content.

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

    Re: formula to concatenate cells with data

    You will need to add a function to your sheet to allow "string" concatenation, concatenation based on the results of a test.

    Let's add the function to your sheet first.
    Press Alt-F11 to open the VBEditor
    Click Insert>Module
    Paste the following code into the window
    Please Login or Register  to view this content.
    (Source)
    The Alt-F11 to close the editor and save your sheet.

    The format for normal simple use is:

    =StringConcat(",",A1:E1)


    But it will allow you to insert a "criteria test" and activate it as an array, like so:
    =StringConcat(",",IF(A1:E1<>"",A1:E1,""),"")
    ...confirmed with CTRL-SHIFT-ENTER.

    When you use the second version, it skips the ones that don't match the test and concatenates the others with the delimiter you specified in the formula.
    Last edited by JBeaucaire; 02-06-2009 at 05:42 PM.
    _________________
    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!)

  4. #4
    Valued Forum Contributor
    Join Date
    11-16-2004
    Location
    Devon UK
    MS-Off Ver
    2010
    Posts
    357

    Re: formula to concatenate cells with data

    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