+ Reply to Thread
Results 1 to 17 of 17

How to prevent Excel from creating a zero in a blank cell when referenced

  1. #1
    Registered User
    Join Date
    05-27-2016
    Location
    Zurich
    MS-Off Ver
    Office 2016
    Posts
    61

    How to prevent Excel from creating a zero in a blank cell when referenced

    Hi All,

    I am having a data sheet which I use as a base for calculations. In a seperate sheet, I reference to this data sheet or use formulas to deduct ratios. I furthermore display graphs over a timeline. See example attached.
    The Issue that I now have is that even though there data sheet has empty cells for the time after may 2016 the references and calculations still show it as 0 and it is therefore plotted on the chart. Is there an Easy way to get rid of this 0?

    Since I do have several worksheets linked I'd rather not enter a formula in each cell as this would take me ages.

    Thanks a lot for your help in advance!!


    Capture.PNG

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    You can use an IF to test the cell for blank.

    Instead of
    =Sheet2!A1
    Use
    =IF(Sheet2!A1="","",Sheet2!A1)

  3. #3
    Registered User
    Join Date
    05-27-2016
    Location
    Zurich
    MS-Off Ver
    Office 2016
    Posts
    61

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Quote Originally Posted by Jonmo1 View Post
    You can use an IF to test the cell for blank.

    Instead of
    =Sheet2!A1
    Use
    =IF(Sheet2!A1="","",Sheet2!A1)
    Hi Jonmo

    I already reference the cells like this: =SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18)
    i.e. if i would have to change each cell individually i will spend days doing that.

    also tried to adapt your approach to my formula (see below) but nothing changed. The output is still 0 instead of BLANK

    =IF(SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18)="";"";=SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18))

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    The result of SUMIFS will NEVER be ""
    It will always be a number (0 IS a number), so you'd have to do
    =IF(SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18)=0;"";SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18))

    But a shorter method (instead of doing sumifs twice) could be done like this
    =IFERROR(1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18));"")

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Try this...

    =IFERROR(1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18));"")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    05-27-2016
    Location
    Zurich
    MS-Off Ver
    Office 2016
    Posts
    61

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Quote Originally Posted by Tony Valko View Post
    Try this...

    =IFERROR(1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18));"")
    Hi Jonmo1 & Tony Valko

    This worked for the cell i.e. the cell is now blank, but unfortunately the chart still shows the line in the bottom instead of just stopping after the last filled cell:

    Capture1.PNG


    Any way I could change that too that if the cell is empty no graph is drawn and as soon as the cell has a value the graph incorporates it?

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    I can't see *.png images on this site.

    Just taking a wild guess...

    =IFERROR(1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18));NA())

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Why bother with the IFERROR, unless for some reason you prefer #N/A instead of #Div/0!

    =1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18))

  9. #9
    Registered User
    Join Date
    05-27-2016
    Location
    Zurich
    MS-Off Ver
    Office 2016
    Posts
    61

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Quote Originally Posted by Tony Valko View Post
    I can't see *.png images on this site.

    Just taking a wild guess...

    =IFERROR(1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18));NA())
    Great! This works for the Chart issue, but just generated another one

    Trying to explain in words in case you can't see the below png. I have three line charts for the development of post (in total, mobile, desktop). In the end I have a pie chart that takes the sum of all the tables and shows %.
    If I use your formula from above, all the sums return #N/A as one or several of the fields which should be summed up are #N/A.

    Any help how i can get around this one now

    Capture3.PNG

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    You can use SUMIF to ignore the errors

    =SUMIF(A1:A100;"<>#N/A")
    or
    =SUMIF(A1:A100;"<>#Div/0!")
    Last edited by Jonmo1; 06-07-2016 at 10:38 AM. Reason: changed , to ;

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Can't see the image.

    To account for errors in a sum function...

    Data Range
    A
    1
    61
    2
    91
    3
    #N/A
    4
    6
    5
    17
    6
    ------


    Try it like this...

    =SUMIF(A1:A5,"< 1E100")

  12. #12
    Registered User
    Join Date
    05-27-2016
    Location
    Zurich
    MS-Off Ver
    Office 2016
    Posts
    61

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    It worked! Thanks Tony!!!

    now, only if you have time it would be interesting to know why I did all of that in order to know it the next time.

    Mainly i'm interested in the bold parts below:

    IFERROR(1/(1/SUMIFS('Data Sheet'!$X:$X;'Data Sheet'!$BA:$BA;'YoY Content'!$A21;'Data Sheet'!$BB:$BB;'YoY Content'!H$18));NA())

    =SUMIF(A1:A5,"< 1E100")

    Cheers,

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    The charting issue is a challenge that has been discussed in some detail here: http://peltiertech.com/mind-the-gap-...g-empty-cells/ Note that a cell containing a function is never truly "blank". the best workarounds depend on chart type, and you sound like you have multiple chart types. You may end up needing multiple copies of the data for the different chart types. One copy of the data where these "blanks" return N/A for line and scatter charts, and another copy where these return "" or 0 for column and pie charts that work better that way. Or spend some time researching other workarounds that may work better for you specific data set.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    The 1/(1/ part is a neat little math trick.
    A very handy trick for hiding 0's in a formula that returns numerical values.

    Take ANY number (the result of your sumifs), say 100 for example

    1/(1/100)

    1/100 = 0.01
    Now you have 1/0.01
    1/0.01 = 100


    Basically, that little calcluation will always return the same original number.
    With the exception of 0
    1/0 = #Div/0!
    The ifferror traps that error.

  15. #15
    Registered User
    Join Date
    05-27-2016
    Location
    Zurich
    MS-Off Ver
    Office 2016
    Posts
    61

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Quote Originally Posted by Jonmo1 View Post
    The 1/(1/ part is a neat little math trick.
    A very handy trick for hiding 0's in a formula that returns numerical values.

    Take ANY number (the result of your sumifs), say 100 for example

    1/(1/100)

    1/100 = 0.01
    Now you have 1/0.01
    1/0.01 = 100


    Basically, that little calcluation will always return the same original number.
    With the exception of 0
    1/0 = #Div/0!
    The ifferror traps that error.

    Thanks a lot Guys!

  16. #16
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    You're welcome.

  17. #17
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to prevent Excel from creating a zero in a blank cell when referenced

    Quote Originally Posted by Dlinen View Post
    =SUMIF(A1:A5,"< 1E100")
    I had to put that space in there or the forum software would interpret that as an HTML code statement and reject it.

    1E100 is scientific notation for the very large number 1 followed by 100 zeros. Scientific notation is a "shorthand" method of expressing very long numbers.

    So, the formula is saying: sum any numbers in the range if they are less than 1 followed by 100 zeros.

+ 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] Returning a blank in a cell if the referenced cell is blank (with a formula) itself
    By milkychips in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2016, 08:57 AM
  2. Replies: 10
    Last Post: 09-12-2015, 02:04 PM
  3. [SOLVED] VBA to prevent saving of excel if cell is blank
    By anuj_sethi1043 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 08-14-2014, 06:37 PM
  4. [SOLVED] Cell referenced in formula has no information displayed (shows blank), return blank cell
    By nunayobinezz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-07-2013, 04:51 PM
  5. Replies: 1
    Last Post: 03-21-2012, 09:41 AM
  6. Returning zero when a referenced cell is blank
    By Lord Tink in forum Excel General
    Replies: 2
    Last Post: 01-04-2007, 05:37 AM
  7. [SOLVED] prevent blank cell in excel worksheet
    By jatman in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-29-2006, 10:08 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