+ Reply to Thread
Results 1 to 4 of 4

IF Cell is Blank, Show Blank, Otherwise do Sum - Not Working

  1. #1
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    IF Cell is Blank, Show Blank, Otherwise do Sum - Not Working

    Hello,

    I am having trouble with a simple IF formula. Please see attached file with my data. I made the cell where I am having trouble with the formula in yellow.

    If the cell in column C is empty I would like my formula in F column to stop summing and return "" or space or "-", but if there is a value in column C it should do the sum, just like in the formulas above it. I would add this formula in all cells in col F of course (except the first cell).

    I think that normally the formula should look like this:
    { =IF (C10="";"";F9+C10-D10) }
    but I also tried this
    { IF (C10="";"";F9+C10-D10) }
    and this:
    { IF C10="" "" F9+C10-D10 }
    and this:
    { IF (C10)="" "" (F9+C10-D10) }
    and this:
    { IF {C10}="" "" {F9+C10-D10} }

    They either show a blank result when it should be a sum, or they show "Syntax error".
    My regional settings are with semicolon, but I also tried with comma and got the same results.

    I've tried several others I can't even remember anymore, to no avail.

    I hope this is possible and someone can help me.
    Attached Files Attached Files
    Last edited by Mrrrr; 09-11-2020 at 02:51 AM.
    To show your appreciation
    Click ★ Add reputation!

  2. #2
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: IF Cell is Blank, Show Blank, Otherwise do Sum - Not Working

    Please attach excel file, not Word document.
    Can't help you without it.
    1. Click on the * Add Reputation if you think this helped you
    2. Mark your thread as SOLVED when question is resolved

    Modytrane

  3. #3
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    Re: IF Cell is Blank, Show Blank, Otherwise do Sum - Not Working

    This question is posted under the Word section because formulas can also be used in Word.

    I know how to do it in Excel, but I need this to work in Word unfortunately.

    *****

    The formula below works if I put 0 instead of "" after =C10.
    For some reason it won't work if in the formula I try to compare C10 to a blank ("").

    This does not work: { IF { =C10 } = "" "" { =F9+C10-D10 } }
    This works: { IF { =C10 } = 0 "" { =F9+C10-D10 } }

    The problem is I have 0 on APR row and the formula in F on that row will be 0 and then all the following results will be wrong.
    Also I might have more consecutive zeroes, so using AND inside IF won't be a solution.

    Does anyone know how I could compare C10 with empty cell ("") instead of 0?
    Last edited by Mrrrr; 09-11-2020 at 10:50 AM.

  4. #4
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    Lightbulb Re: IF Cell is Blank, Show Blank, Otherwise do Sum - Not Working

    After more googling during the weekend, including for various alternative ideas (eg. add a space in the cell with 0 while leaving the blank cell blank), I found out that one can't refer to a blank cell in Word. Quoting user Cindy M from wordbanter in a post from 2005: "you can't test for an "empty" cell, because a cell in Word is NEVER empty. It always holds the end-of-cell marker (combination of a paragraph mark, plus a range that contains a pointer to the cell formatting and structure information in the document's binary structure). You can test for a value of 0, however. If the cell contains nothing, it will return 0."

    In my case, as stated in the post above, referring to zero doesn't help because I have zero values in cells and still need the formula to calculate and show the result for those cells.

    I tried to use the end-of-cell marker character (char 0164) but I haven't found a syntax to use such characters in Word formulas.

    *****

    However, I found an acceptable alternative that works for me - might not for others. A rather "unorthodox" alternative. I'll explain why.

    Since I can't find a formula to return the desired blank cell in column F in case the cell in column C is empty, I thought of formatting the text in column F and make text white in F if cell in C is empty.

    If you downloaded my file from post #1 you noticed that I have bookmarks for columns C and D for each month.
    I have to complete some Word documents monthly and do some math inside them.
    So I use HTA (HTML for Applications) combined with VBA code to open .doc files, insert values, refresh formulas, save and close .doc files with just 1 click after typing the desired values in the HTA textboxes.

    For the file I attached in post #1 I made the font color in column F in white for months AUG+SEP+OCT+NOV+DEC (these are the cells corresponding to column C empty cells).

    For this to work I also created bookmarks for cells in column F, like T1_jan_INV, T1_feb_INV and so on until T1_dec_INV.
    I added a few lines of VBA to my HTA file so that when I enter values in bookmarks for one month it also colors the text in black for that month in INV column.

    Eg. in the file from post #1
    - I added bookmarks for cells in column F
    - AUG is empty and the text in INV column is white (the result of the formula is normally not visible and won't be visible in case I print the document)
    - I use HTA to insert values in bookmarks T1_aug_1 and T1_aug_2 (columns C and D cells for aug month)
    - the few lines of VBA I added will color the text in the corresponding bookmark - which is T1_aug_INV - in black, thus making my sum visible

    *****

    I'm still open to any suggestions on a way to solve my issue from within the formula.
    This might also help others who don't use code to insert values or don't want VBA to color text.

+ 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] SUMPRODUCT When Cell is blank then show blank not Zero 0
    By farrukh in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-06-2020, 12:16 AM
  2. [SOLVED] Dragging formula to add two columns, but need to show blank when other cell is blank
    By doesntexist in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-05-2018, 11:18 PM
  3. [SOLVED] Reference cell formula returning 0 when BLANK, need BLANK to show
    By williamc in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-31-2016, 04:23 PM
  4. Averaging with a blank cell, needs to show blank calculation
    By Pstreicher in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2015, 08:08 AM
  5. If cell blank OR another cell blank then show blank, if not display value
    By stevop622 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-09-2013, 04:07 AM
  6. [SOLVED] If one cell contains #, & other cell is blank, show message & require blank be resolved
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-19-2012, 02:23 PM
  7. Replies: 1
    Last Post: 09-23-2010, 01:24 PM

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