+ Reply to Thread
Results 1 to 5 of 5

How to stop excel from concatenating blank cells

  1. #1
    Registered User
    Join Date
    04-14-2017
    Location
    Amsterdam, NL
    MS-Off Ver
    2016
    Posts
    18

    How to stop excel from concatenating blank cells

    Hi, I am preparing a worksheet to easily enter opening hours into our backend:


    Year Month Day Hours
    1 2021 12 24 09:00-15:00
    2 2021 12 25 Closed
    3 2022 1 1 Closed
    4
    5
    6
    7
    8
    9
    10


    I am using the following concatente formula for the whole sheet:

    =CONCATENATE(B2,"-",C2,"-",D2,"=",E2,";",B3,"-",C3,"-",D3,"=",E3,";",B4,"-",C4,"-",D4,"=",E4,";",B5,"-",C5,"-",D5,"=",E5,";",B6,"-",C6,"-",D6,"=",E6,";",B7,"-",C7,"-",D7,"=",E7,";",B8,"-",C8,"-",D8,"=",E8,";",B9,"-",C9,"-",D9,"=",E9,";",B10,"-",C10,"-",D10,"=",E10,";",B11,"-",C11,"-",D11,"=",E11,";")

    to get the following output:

    2021-12-24=09:00-15:00;2021-12-25=Closed;2022-1-1=Closed;--=;--=;--=;--=;--=;--=;--=;

    I can't figure out how to have excel skip a cell if it is blank; i.e. I don't want the "--=;--=;--=;--=;--=;--=;--=;" if someone doesn't fill in all possible days.

    See attachment.

    Thank you for your help!
    Attached Files Attached Files
    Last edited by toddb511; 08-25-2021 at 08:40 AM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: How to stop excel from concatenating blank cells

    this function may help.

    =SUBSTITUTE( old_formula, "--=;" , "")

    Regards.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,320

    Re: How to stop excel from concatenating blank cells

    Try

    =SUBSTITUTE(CONCATENATE(B2,"-",C2,"-",D2,"=",E2,";",B3,"-",C3,"-",D3,"=",E3,";",B4,"-",C4,"-",D4,"=",E4,";",B5,"-",C5,"-",D5,"=",E5,";",B6,"-",C6,"-",D6,"=",E6,";",B7,"-",C7,"-",D7,"=",E7,";",B8,"-",C8,"-",D8,"=",E8,";",B9,"-",C9,"-",D9,"=",E9,";",B10,"-",C10,"-",D10,"=",E10,";",B11,"-",C11,"-",D11,"=",E11,";"),"--=;","")

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: How to stop excel from concatenating blank cells

    Hi there,

    Take a look at the attached version of your workbook and see if it does what you need. It uses a VBA function with the following code:

    Please Login or Register  to view this content.
    An advantage of this approach is that no code modifications are required if the data range is increased or decreased vertically.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files
    Last edited by Greg M; 08-25-2021 at 06:36 AM. Reason: Comment re advantage added

  5. #5
    Registered User
    Join Date
    04-14-2017
    Location
    Amsterdam, NL
    MS-Off Ver
    2016
    Posts
    18

    Re: How to stop excel from concatenating blank cells

    Thanks for your replies! I used the SUBSTITUTE option as that was the most straightforward and least hassle. It works perfectly for my purposes. Thanks again

+ 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. Replies: 2
    Last Post: 03-14-2018, 08:26 AM
  2. Replies: 2
    Last Post: 03-14-2018, 02:19 AM
  3. [SOLVED] how to stop formula when cells are blank?
    By geopiet in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-12-2017, 12:24 AM
  4. [SOLVED] How to ignore blank cells while concatenating multiple cell values
    By RASARO72 in forum Excel General
    Replies: 15
    Last Post: 12-30-2016, 03:13 AM
  5. Want to stop my concatenate function concatenating duplicates
    By bm1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2010, 04:41 AM
  6. [SOLVED] STOP BLANK CELLS
    By JFAZ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-17-2006, 12:40 PM
  7. How do I stop Excel from treating blank cells as zero?
    By Michael Gillie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-13-2005, 07:06 AM

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