+ Reply to Thread
Results 1 to 4 of 4

Combine text from multiple cells, but not when cell is blank

Hybrid View

  1. #1
    Registered User
    Join Date
    04-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2008 for mac
    Posts
    2

    Combine text from multiple cells, but not when cell is blank

    Hi There,

    This is my first post, so hopefully I form the question correctly. I am using Excel 2008 for mac and would like to do the following.

    Where I have text in A1, A2, A3 and sometimes in A4 and A5, for example:

    A1 = Hello
    A2 = Goodbye
    A3 = Hello Again
    A4 = (blank)
    A5 = (blank)

    I need a formula that combines the text from A1 to A5 into one cell, with "and" in between each set of text, but if any cell is blank does not include the "and" and then a space.

    For example, when I use the formula:

    =CONCATENATE(A1," and ",A2," and ",A3," and ",A4," and ",A5)

    I of course get:

    Hello and Goodbye and Hello Again and and

    I would like to get:

    Hello and Goodbye and Hello Again

    But when A4 and A5 have text, for example:

    A1 = Hello
    A2 = Goodbye
    A3 = Hello Again
    A4 = Goodbye Again
    A5 = Hello Again

    That the same formula results in:

    Hello and Goodbye and Hello Again and Goodbye Again and Hello Again

    Is there a way to do this?

    Thank you for your help!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Combine text from multiple cells, but not when cell is blank

    Hi jbparsons and welcome to the forum,
    Try this:
    =IF(A1<>"", A1,"")& IF(A2<>""," and " & A2,"") & IF(A3<>""," and "& A3,"") & IF(A4<>""," and "&A4,"") & IF(A5<>""," and "&A5,"")
    See the attached.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    04-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2008 for mac
    Posts
    2

    Re: Combine text from multiple cells, but not when cell is blank

    This is very helpful. I did come across a new issue though, which I didn't explain as a requirement in my first post. For the cells that come back blank, they are actually calling on data with a formula where if there is no data it will return "#N/A" rather than a blank cell. Is there any way to adjust this equation to still work the same way, if the cell has "#N/A" in it rather than a true blank cell?

    Thanks again for the help!

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Combine text from multiple cells, but not when cell is blank

    Hi,
    Look to see if you have an IfError function on that MAC 2008 version. That would be the direction I'd be going.

+ 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