Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Returning Zero when a Referenced Cell is Blank

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Returning Zero When a Referenced Cell is Blank.

If you have a formula in a worksheet, and the cell referenced by the formula is blank, then the formula still returns a zero value. For instance, if you have the formula =A3, then the formula returns the contents of cell A3, unless cell A3 is blank. In that case, the formula returns a value of zero.

This seems to be related to the idea that it is impossible for a formula to return a blank value, when "blank" is used synonymously with "empty." You can, however, expand your formula a bit so that it returns an empty string. Instead of using =A3 as your formula, you would use the following:

=IF(ISBLANK(A3),"",A3)

This formula uses ISBLANK, which returns either True or False, depending on whether the referenced cell (A3) is blank or not. The IF function then returns an empty string ("") if A3 is blank, or it uses the value in A3 if A3 is not blank.

Regardless of what the formula returns, you can still use its result in other formulas, and it will work fine. Even if it returns an empty string, it is still treated by other formulas as if it contained zero. In areas where treating the cell as if it contained zero might be problematic (such as when you are charting the results of the formula), then you can modify the formula a bit, as shown here:

=IF(ISBLANK(A3),NA(),A3)

This formula returns the #N/A error if A3 is blank. This error propagates through other formulas that reference the formula, but the #N/A error is ignored completely when charting.

While the above solutions are satisfactory for most people, some people would really like to see a target cell be truly blank if the source cell is blank. For instance, you might want cell B7 to be blank if cell A3 is blank. If you put a formula in cell B7 (as already discussed), then cell B7 is not truly blank—it contains a formula.

If this is your goal—true "blankness"—then you can only achieve it through the use of a macro. The macro will need to check to see if the source cell was changed. If it was, then whatever is in the source needs to be copied to the target cell.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim rMonitor As Range
    Dim rTarget As Range

    Set rMonitor = Range("A3")
    Set rTarget = Range("B7")

    If Not Intersect(Target, rMonitor) Is Nothing Then
        rMonitor.Copy rTarget
    End If

    Set rMonitor = Nothing
    Set rTarget = Nothing
End Sub

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2174) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Returning Zero When a Referenced Cell is Blank.

Related Tips:

Got the Time? Understanding the ins and outs of working with times and dates can be confusing. Remove the confusion--ExcelTips: Times and Dates is an invaluable resource for learning how best to work with times and dates. Check out ExcelTips: Times and Dates today!

 

Comments for this tip:

Michael (Micky) Avidan    29 Aug 2014, 13:29
I don't see any problem in using: =A3&""
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL
Jessie    28 Aug 2014, 12:24
I have the following formula:
=DATE(YEAR(D52)+E52,MONTH(D52),DAY(D52))

I want to have it blank if D52 is empty. Can you please show me what that entire formula would look like?
Alpesh    10 Jul 2014, 01:06
Thank you so much, very helpful...keep it up.
Jojo    11 Jun 2014, 19:03
Yes I am having weird issue on my tie in workbook that takes a vroom up formula and returns a date from another sheet. However when the cell is empty it gives me the 00-Jan-00 output but I want the summary book to show blank if their is no date yet. So I tried to attach the if is blank formula and I get circular reference error and no change to output with weird date. Help!
Just Plain Eric    21 Apr 2014, 13:12
Kris, I have a few comments:

First, when testing multiple cells for blank-ness, you might prefer to use the COUNT function, which returns the number of cells that are filled.
Second, not sure if you meant to do this or not, but you missed C46 in your ISBLANK tests. This could cause your MAX function to return zero when you expect it to return blank.

With these changes, your formula would become:
=IF(COUNT(C40,C43,C46,C49)=0,"",MAX(C40,C43,C46,C49))

Also, the reason your formula returns "1/0/1900" is because the cell is formatted as a date. If you change the number formatting to a number format or General, that result will change to a zero, which is how Excel (and every other SS program I've ever had to work with for that matter) treats a blank cell. If that formula is just a direct reference to C36, then C36 can't actually be blank, and C36 is probably picking up a blank from C46 and returning 0 (zero).
mbszameer    30 Apr 2013, 12:29
thank you very much, this site is helpful
Kris McBride    17 Apr 2013, 19:55
The NA() hint helped but what if I dont want it to return #na?. I have a formula in C36 as follows: =if(and(isblank(C40),isblank(c43),isblank(c49)),"",max(C40,C43,C46,C49)) which returns a blank cell. I later have a separate tab referencing C36 with the same formula referencing different cells that I want C36 included in but because the second formula treats C36 like it has a zero in it when in acutality is it blank the final formula returns the "1/0/1900" date instead of being blank. Obviously I am dealing with dates and these are details sheets compliling to an overview sheet. Hope you can help.
Jonas    05 Feb 2013, 05:10
I had to use semicolons to get the formular to work.

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 3+4? (To prevent automated submissions and spam.)
 
          Commenting Terms
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2014 Sharon Parq Associates, Inc.