Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Returning a Blank Value

The purpose of formulas is to return a value based upon a calculation or comparison. For instance, if you use the formula =1+1, the sum is calculated and the value 2 is returned. There might be times, however, when you want to use a formula and actually return nothing. For instance, you might want to compare a value in a cell to some constant and return a numeric value if they are equal or return nothing if they are different.

The problem is that a formula must, under all circumstances, return something—for it not to do so would go against the very purpose of formulas. There are two ways to approach the problem, and how you do so will affect what you can and cannot do with your results. Consider the following formula:

=IF(A1=0,"",1)

In this instance, the cell containing this will contain a blank value ("") if A1 is 0 or it will contain a numeric value (1) if it is not 0. In either case, something is being returned. You could, however, use the following variation on the formula:

=IF(A1=0,,1)

The only difference here, of course, is that the quote marks have been removed. Interestingly enough, in this case Excel assumes there is a zero between the two consecutive commas, and if A1 is 0, the formula returns a 0. Again, formulas must return something.

The way that Excel's other functions interpret the results of these two formulas is also very interesting. It is instructive to look at how the COUNT, COUNTA, and COUNTBLANK functions interpret the results.

COUNT is used to count the number of cells in a range that contain numeric values. If the cells contain text, or if they are empty, they are ignored. In the case of our formulas, if you use the first formula, COUNT counts the cell if A1 is not zero. If you use the second formula, COUNT will always count the result, since it always returns either 0 or 1, which are both numeric.

COUNTA is used to count the number of cells in a range that contain anything. Regardless of which formula you use, COUNTA will count the cell since formulas always return something. (It can also be argued that COUNTA counts the cell because it contains a formula, but that is probably a fine semantic difference.)

COUNTBLANK examines cells and counts them only if they are blank. In the case of the first formula, COUNTBLANK will count the cell only if A1 is 0. In the case of the second formula, COUNTBLANK will never count the cell, since the formula always returns a 0 or 1 and is therefore never blank.

The above discussion applies if the COUNT, COUNTA, or COUNTBLANK functions are evaluating the results of a series of cells that actually contain formulas. However, if the range includes cells that are really blank (i.e., they contain nothing, not even a formula), then that can affect what is returned by the functions. Blank cells don't affect the results returned by either COUNT or COUNTA, but they do affect the results returned by COUNTBLANK.

What does all this mean? It means that a cell that contains a formula is never really, truly blank—only cells with nothing in them are blank. How the result of the formula is interpreted, however, depends on the Excel functions being used to perform the interpretation. Since different functions interpret formula results differently, you need to be concerned with what you really want to find out about the formula results, and then use the function that will help you best determine that information. If you don't get the result you expect with a particular function, search around—chances are good that Excel has a different function you can use to get the desired results.

That being said, if you have a range of cells that all contain formulas similar to =IF(A1=0,"",1), and you want to delete the formulas in the cells that return a blank value (""), you can quickly do so by following these steps:

  1. Select the range containing the formulas in question.
  2. Press F5. Excel displays the Go To dialog box. (See Figure 1.)
  3. Figure 1. The Go To dialog box.

  4. Click Special. Excel displays the Go To Special dialog box. (See Figure 2.)
  5. Figure 2. The Go To Special dialog box.

  6. Make sure the Formulas radio button is selected.
  7. The only check box that should be selected under Formulas is Text.
  8. Click OK. Excel selects all cells where the formula returned a text value. (This should be all the formulas that returned "".)
  9. Press Delete.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2814) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

Related Tips:

A Picture is Worth Thousands! Your worksheets are not limited to holding numbers and text. You can also add graphics or easily create charts based on your data. Excel Graphics and Charts, available in two versions, helps you make your graphics and charts their absolute best. Check out Excel Graphics and Charts today!

 

Comments for this tip:

Richard Devereux    23 Apr 2013, 05:13
can anyone help, basically i have 4 columms in excel the first 3 are raw data and the 4th is a calculation of that data. i want a formula that when there is no data will actually leave a blank cell.

the reason i need a blank cell is i want to work out standard deviation of the 4th columm and the formula im currently using seems to produce a zero rather than blank

this is the formula ive tried using

=IF(ISBLANK(D62),"",(D62^4+E62^4+F62^4)^0.25)

so if d62 is empty there is no raw data and i want to then produce a blank cell
Ramesh    05 Apr 2013, 07:13
=IF(AC121<35%,1,"") in this condition required if cell is blank then i need result is blank
paul    29 Mar 2013, 10:04
not for nothing but with this technique you need to keep hitting delet and enter like a million times..... not a very efficient or effective way to do something...
kay    19 Nov 2012, 15:01
I'm working with text. If formula =(other file) A8 pulls text to cell A8 this file, do v-lookup for cell A9. If cell A8 does not pull text, I do not want anything done to A9.

Can anyone help me with this?
Prash    31 Oct 2012, 06:31
Just worked out a better method which doesn't rely on datatypes. Basically you force an error by dividing by zero:

=IF(LEN(A1)>0,A1,1/0)

Then do a Go To > Special > Formula > Errors > OK > Delete
Ian    18 Oct 2012, 07:03
Curiously the text "#N/A" is also treated as empty, even if you have actually typed it into the cell
JC    11 Sep 2012, 15:50
Awesome tip from CK. My formula used to look like this:

=IF(B49<R$2,"",IF(B49>R$3,"",B49))

and now looks like this:

=IF(B49<R$2,NA(),IF(B49>R$3,NA(),B49))

and it successfully shows #NA, allowing my to graph series with NA values.
CK    05 Sep 2012, 07:42
A way for excel not to plot "" or " " as zeros is to fill in the blanks with NA()

I use this formula:

=if(a1>0,a1,na())

which will produce values or #NA in the cell.
When graphing, #NA does not show up, even allowing you to have gaps in your graphs.

Since #NA can screw up other functions/operations, I copy my data (Vlookup) to another tab to create the data with #NA specifically for graphing.


Joel    23 Jul 2012, 12:09
Interesting that the "CountBlank()" function counts the "" as a blnak cell, but the "IsBlank()" function does not... i.e., if the value returned from the if-then statement is "", the IsBlank() function still returns FALSE.
Kevin    24 Jun 2012, 16:50
Unfortunately the graphing function in Excel seems to treat a cell populated with " " or "" as a zero. I don't know what to put in the cell. The formula and circumstance I'm using is similar to the previous comment from jshah:

=IF(ISNA(VLOOKUP(SomeCode))=TRUE,"",VLOOKUP(SomeCode))
jshah    03 Nov 2011, 14:15
This does not work in my scenario.. I am working with Excel worksheets that have to do with numbers and Vlookups.

Formula pasted down a large range down the column is for instance:

=IF(ISERROR(VLOOKUP(SomeCode)),"",VLOOKUP(SomeCode))

So if it's an error then it equals "" and if not it equals a number value returned by Vlookup. After that I do paste special to all this, leaving just the numbers and what should be empty cells. When I go to the "Go To..." > Special > Blank Cells selection.. it does not select any of the blank ones. Unless I go to each one and click delete. As this is a huge workbook of numbers I need a workaround.

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 2+3? (To prevent automated submissions and spam.)
 
 
 

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

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Family

Gardening

Health

Home Improvement

Legal Help

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

School and Schooling

Weddings

WindowsTips

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 © 2013 Sharon Parq Associates, Inc.