+ Reply to Thread
Results 1 to 5 of 5

concatenate and add text only if second cell is not blank

  1. #1
    Registered User
    Join Date
    02-09-2011
    Location
    ft. lauderdale, fl
    MS-Off Ver
    Excel 2010
    Posts
    16

    Angry concatenate and add text only if second cell is not blank

    I want to concatenate 2 cells, only if the second cell is not blank and add text in between the cells. for example cell A1 is a name and cell b1 is a name, I want to add both names together so that they come out like “Name 1 and Name 2”. If there is a blank 2nd cell, I just want the first name to show up without the “and”. I tried but can't seem to get rid of the "and" if the second cell is blank. =(A1&"AND"&A2) I have tried =Trim(a1&"and"&A2), I have also tried using If(a2<>" ") in that string... I still get the "and". I've spent hours searching for an answer...

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,069

    Re: concatenate and add text only if second cell is not blank

    =A1&IF(A2="",""," and "&A2)

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-09-2011
    Location
    ft. lauderdale, fl
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: concatenate and add text only if second cell is not blank

    Thank you so much, I must have had every variation of this string...I had forgot to mention that I would still need the first cell to show up - even if the second cell is blank...this is what my formula looks like after using what was posted....

    ='Client Data Input'!B11&IF('Client Data Input'!F11="",""," and "&'Client Data Input'!F11)

    how do i add, show b11 no matter what?

    makes sense?

    again, thanks so much...progress gives me hope

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,069

    Re: concatenate and add text only if second cell is not blank

    That's exactly what you should be getting.

    If you're not, please post a sample workbook.

    Regards

  5. #5
    Registered User
    Join Date
    02-09-2011
    Location
    ft. lauderdale, fl
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: concatenate and add text only if second cell is not blank

    You are right...there was an error in my formula...thank you again for the help....

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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