Sub topic 10
Detecting and Handling Blank Cells
This chapter assumes you can write a basic IF formula, use comparison operators, and compare text in quotes. It also assumes you can copy a formula down a column. Here you will learn how to make IF react to empty cells so your sheet stays clean.
Why blanks need attention
When you copy a formula down a long column, some rows may not have data yet. Without a check, the formula still runs. A blank cell counts as 0 in math, so you may see 0 or a misleading result in rows that should look empty.
Suppose column B holds quantities and column C holds prices. The formula =B2*C2 returns 0 for a row where both cells are empty. A report full of zeros looks like real data when it is not.
Testing for an empty cell
The simplest test compares a cell with an empty string, written as two double quotes with nothing between them.
=IF(A2="","","Entered")This formula reads: if A2 is empty, show nothing. Otherwise show "Entered". The first "" is part of the test. The second "" is the value returned when the test is true.
You can also use the ISBLANK function.
=IF(ISBLANK(A2),"Missing","Present")ISBLANK returns TRUE only when the cell has nothing in it at all.
Two ways to test, and one difference
The two tests are not identical. The table shows how each one treats different cell contents.
| Cell A2 contains | `A2=""` | `ISBLANK(A2)` |
|---|---|---|
| Nothing at all | TRUE | TRUE |
| A formula that returns `""` | TRUE | FALSE |
| A single space typed by the user | FALSE | FALSE |
| The number 0 | FALSE | FALSE |
Use A2="" when the cell might hold a formula that returns an empty string. Use ISBLANK when you only want to catch cells that were never filled in.
Leaving the result empty
The most common use is to hide results until the inputs exist.
=IF(A2="","",B2*C2)When A2 is empty, the result cell shows nothing. When A2 has a value, the formula multiplies B2 by C2. Copy it down the whole column and only rows with data will display a result.
Note that the test looks at A2 but the calculation uses B2 and C2. Pick the cell that signals the row is in use. If the calculation needs several inputs, you can check them together with OR.
=IF(OR(B2="",C2=""),"",B2*C2)This shows nothing if either input is missing.
Reversing the test with NOT or `<>`
You can also write the test the other way round, asking whether a cell has content.
=IF(A2<>"","Done","")The operator <> means "is not equal to". This formula returns "Done" when A2 contains something, and nothing otherwise. The result is the same as the earlier version with the branches swapped. Choose whichever reads more naturally to you.
How the decision flows
Worked example
Imagine a task list. Column A holds the task name and column B holds a completion date. You want column C to say "Open" for tasks without a date, and "Closed" for tasks with one. Rows without a task name should stay empty.
=IF(A2="","",IF(B2="","Open","Closed"))The outer IF checks the task name first. If A2 is empty, the row is unused and the result is empty. Otherwise the inner IF checks the date. Order matters here. Testing A2 first stops unused rows from showing "Open".
Common slips
- Writing
A2=" "with a space inside the quotes. This tests for a space, not an empty cell. - Forgetting the quotes and writing
A2=. Excel rejects the formula. - Using
A2=0to find blanks. This is TRUE for blank cells but also for real zeros, so you may hide valid data.
Exercise
Column B holds sales amounts and column C holds a commission rate. Write a formula for D2 that shows nothing when B2 is empty, and otherwise multiplies B2 by C2.
Show answer
=IF(B2="","",B2*C2)
Exercise
A cell contains a formula that returns "". Does ISBLANK return TRUE or FALSE for it, and which test would you use instead?
Show answer
ISBLANK returns FALSE because the cell contains a formula. Use the test A2="" instead, which returns TRUE.