Check if a cell is blank, a number or text in Excel
ISBLANK, ISNUMBER and ISTEXT answer TRUE or FALSE about a cell. Why a cell that looks empty is not always blank, and how to use each test inside IF.
To check if a cell is blank, use =ISBLANK(A1). It is TRUE only
when A1 has nothing in it at all. =ISNUMBER(A1) and
=ISTEXT(A1) check for a number or for text.
All three give TRUE or FALSE, so each one fits inside IF as the test. The catch is ISBLANK. A cell can look empty and still not be blank.
Here is a list of supplier invoices from an accounts system. You want 2 checks. Will each amount add up? And which invoices are not paid yet?
| Row | A | B | C |
|---|---|---|---|
| 1 | Invoice | Amount | Paid on |
| 2 | INV-501 | 480 | 12 Jan 2027 |
| 3 | INV-502 | 95 | |
| 4 | INV-503 | ||
| 5 | INV-504 | n/a | |
| 6 | INV-505 | 1250 | 15 Jan 2027 |
Some cells are not what they look like. B3 came from the system as text. C4 holds one space,
typed by someone to clear the cell. C5 holds a formula that gives "",
which is empty text.
Will the amount add up?
=SUM(B2:B6) gives 1730. The amounts on screen make 1825. SUM
skips B3, because 95 is text there. It gives no warning.
ISNUMBER finds it. In D2, type this and fill it down:
=IF(B2="","Missing",IF(ISNUMBER(B2),"OK","Not a number"))
| Row | Amount | ISNUMBER | ISTEXT | Check |
| 2 | 480 | TRUE | FALSE | OK |
| 3 | 95 (text) | FALSE | TRUE | Not a number |
| 4 | nothing | FALSE | FALSE | Missing |
| 5 | n/a | FALSE | TRUE | Not a number |
| 6 | 1250 | TRUE | FALSE | OK |
ISNUMBER is FALSE for B3 and B5, and ISTEXT is TRUE for both. Neither will add up. For an empty cell, both tests are FALSE. That is why the formula checks for empty first.
To mark only the text, use ISTEXT as the test.
=IF(ISTEXT(B2),"Fix","") says Fix in rows 3 and 5, and nothing
in the other rows.
=COUNT(B2:B6) gives 2. COUNT counts only real numbers. If COUNT
is smaller than the rows you expect, some amounts are text. The
clean up text article shows how to fix
them.
Is the invoice paid?
The first idea is to mark a row as unpaid when the paid date is blank:
=IF(ISBLANK(C2),"Unpaid","Paid")
Filled down, only row 3 says Unpaid. Rows 4 and 5 say Paid, and neither invoice has a date.
ISBLANK is FALSE for C4 because a space is a character. It is FALSE for C5 because a formula is not nothing, even when it gives empty text. Here is every test on the 4 kinds of cell:
| Row | What C holds | ISBLANK | =C2="" | LEN(TRIM())=0 | ISNUMBER |
| 2 | a date | FALSE | FALSE | FALSE | TRUE |
| 3 | nothing | TRUE | TRUE | TRUE | FALSE |
| 4 | a space | FALSE | FALSE | TRUE | FALSE |
| 5 | a formula that gives "" | FALSE | TRUE | TRUE | FALSE |
Use ="" for cells that look empty
=C2="" is a comparison. It asks if C2 is equal to empty text. It
is TRUE for a cell with nothing in it, and TRUE for a formula that gives
"".
=IF(C2="","Unpaid","Paid") marks rows 3 and 5 as Unpaid. Row 4
still says Paid, because of the space.
This is the test most people should use instead of ISBLANK. Use ISBLANK only when you must tell a
formula's "" apart from a truly empty cell.
The space you cannot see
=LEN(C4) gives 1. LEN counts characters, so it shows the space.
TRIM removes spaces at the start and end. So this test ignores spaces:
=IF(LEN(TRIM(C2))=0,"Unpaid","Paid") marks rows 3, 4 and 5 as
Unpaid. That is the right answer for all 5 rows.
Better: test for what should be there
A paid date is a date, and a date in Excel is a number. So you can skip the question of empty cells and ask if C2 holds a number:
=IF(ISNUMBER(C2),"Paid","Unpaid")
Rows 2 and 6 say Paid. Rows 3, 4 and 5 say Unpaid. It also says Unpaid for a note like "paid?" or a date that came in as text. Those need a check too.
What I do: when a column should hold numbers or dates, I test with ISNUMBER. When it should
hold text, I test with =LEN(TRIM(C2))=0. I use ISBLANK very
rarely. For why a date counts as a number, see
Excel dates are numbers.
COUNTBLANK does not agree with ISBLANK
=COUNTBLANK(C2:C6) gives 2. It counts C3 and C5. COUNTBLANK counts
a formula that gives "" as blank, and ISBLANK does not. Neither
of them counts the space in C4.
So a sheet can say 2 cells are blank in one place and 1 in another. Both are right by their own rule. Pick one test for a sheet and use it everywhere.
Which test to use
-
Looks empty, including formulas that give "":
=A1="" -
Data typed or pasted by people:
=LEN(TRIM(A1))=0 -
Should hold a number or a date:
=ISNUMBER(A1) -
Truly nothing in the cell:
=ISBLANK(A1)
For more practice with IF and a test, see the IF function exercises. The lessons below use the same tests. Each lesson is a real sheet you type into, and each answer is checked when you press Enter.