+ Reply to Thread
Results 1 to 6 of 6

Combine text in multiple cells if not blank

  1. #1
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Combine text in multiple cells if not blank

    I am trying to write a formula that will combine text from 4 cells if if they are not blank. For example, I have 4 columns titled Sales Rep 1, 2 3 and 4. In the cells below are the names of the sales reps. If sales rep 1 is empty then the result will be empty. That is an easy formula to write. If Sales rep 2 is empty it will default to just sales rep 1. This too is an easy formula. If sales rep 3 is empty then it defaults to combine sales rep 1 and 2. I was able to make that work too. The problem is adding a 4th sales rep. See attached excel to see what I mean.

    Thanks in advance for your help.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Combine text in multiple cells if not blank

    I'd use this array formula:

    =ConcatY(IF(B2:E2<>"",B2:E2,""))

    combined with this code (pasted into a module, right click on sheetname to view)
    Please Login or Register  to view this content.

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...

    Enable macros on opening.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Combine text in multiple cells if not blank

    Hope this works
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,909

    Re: Combine text in multiple cells if not blank

    One way...

    =IF(COUNTA(B2:E2)=0,"",MID(IF(B2="","","/"&B2)&IF(C2="","","/"&C2)&IF(D2="","","/"&D2)&IF(E2="","","/"&E2),2,500))

  5. #5
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Re: Combine text in multiple cells if not blank

    Perfect. That worked great as I was hoping to use a non-array formula as I also need to use it in my Google Sheets file. Thank you!

  6. #6
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Re: Combine text in multiple cells if not blank

    Thank you. I was looking for a non array formula but I see yours works too. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Combine multiple cells text into one cell, skip blank cells.
    By T15K in forum Excel General
    Replies: 6
    Last Post: 12-05-2014, 09:49 PM
  2. Combine text in multiple cells if adjacent column is blank
    By problematic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2012, 01:52 PM
  3. Replies: 3
    Last Post: 04-27-2011, 12:59 AM
  4. combine text of multiple cells
    By Roger Govier in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 09:05 PM
  5. [SOLVED] combine text of multiple cells
    By Uncle O in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  6. combine text of multiple cells
    By Uncle O in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  7. [SOLVED] combine text of multiple cells
    By Uncle O in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  8. [SOLVED] combine text of multiple cells
    By Uncle O in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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