Return Blank Instead of Zero in Excel (IF Formula)
Learn how to return blank instead of zero in Excel: =IF(A2-B2=0,"",A2-B2). Plus blank if no data, blank on error, and the ""...
=IF(A2-B2=0,"",A2-B2)You have a column of statuses — Completed, In Progress, Pending — and you want to know how many there are. COUNT gives you 0. That is not a broken formula: COUNT counts numbers only, and your column has none. The function you want is COUNTIF, and the formula is one line: =COUNTIF(range, "*"), where the asterisk means any text. The same function counts a specific word, cells that contain a word, and — with its partner COUNTIFS — rows that meet two conditions at once. This guide gives you that formula first, works it through on one ten-row table so every result can be checked, and covers the two traps: the match that is not case-sensitive, and the “not equal to” count that quietly includes the blank cells.
Quick takeaway: COUNT counts numbers only. COUNTIF counts text.
=COUNTIF(B2:B11, "*") — how many cells contain any text.=COUNTIF(B2:B11, "Completed") — how many say exactly Completed.=COUNTIF(B2:B11, "*Progress*") — how many contain the word Progress.=COUNTIFS(B2:B11, "Completed", C2:C11, "High") — how many meet both conditions.
One project list, ten rows. Every example on this page runs on it, so every result can be checked against the same numbers. Row 7 is blank on purpose — it is the trap:
| Row | B: Status | C: Priority |
|---|---|---|
| 2 | Completed | High |
| 3 | In Progress | Low |
| 4 | Completed | High |
| 5 | Pending | Medium |
| 6 | Completed | High |
| 7 | (blank) | Low |
| 8 | In Progress | Medium |
| 9 | Completed | High |
| 10 | Pending | Low |
| 11 | Completed | Medium |
=COUNTIF(B2:B11, "*")
Result: 9. The asterisk matches any sequence of characters, so every cell with text is counted — and the blank row is not. COUNTIF takes two arguments: the range to check, and the criterion — the rule a cell has to meet. Text criteria go in double quotes. This is the formula the keyword asks for, and it is the one to reach for first.
=COUNTIF(B2:B11, "Completed")
Result: 5. The formula scans the range and counts every cell that exactly matches “Completed”. The match is not case-sensitive: “completed”, “Completed” and “COMPLETED” all count. That is usually what you want — but if you ever need a case-sensitive count, COUNTIF cannot do it; use =SUMPRODUCT(--EXACT(B2:B11,"Completed")) instead.
To count from a word typed in a cell instead of in the formula, put the word in E1 and reference it:
=COUNTIF(B2:B11, E1)
Change E1 and the count updates — no editing the formula.
Exact match is not always what you want. A feedback column has long sentences, and you want every cell that mentions the word “support”. Put asterisks around the word:
=COUNTIF(B2:B11, "*Progress*")
Result: 2. The asterisks mean “anything before and anything after”, so “In Progress” matches twice. The two wildcards are:
| Wildcard | Matches | Example | Result |
|---|---|---|---|
| * | Any number of characters | =COUNTIF(B2:B11, "*") | 9 — any text |
| word | The word anywhere in the cell | =COUNTIF(B2:B11, "*Progress*") | 2 |
| ? | Exactly one character | =COUNTIF(D2:D5, "??") | 3 — “A1”, “B2”, “C3” (not “D44”) |
The ? counts codes and short IDs: “A1”, “B2” and “C3” are two characters each, so they match “??”; “D44” is three characters, so it does not.
One condition is COUNTIF. Two or more is COUNTIFS — the same idea, repeated as range/criteria pairs, with AND logic: a row is counted only when every pair matches. How many projects are Completed AND High priority?
=COUNTIFS(B2:B11, "Completed", C2:C11, "High")
Result: 4. Rows 2, 4, 6 and 9 are Completed and High; row 11 is Completed but Medium, so it does not count. The rule of thumb: if your question has the word “and” in it, use COUNTIFS. If it has one condition, COUNTIF is shorter to type. COUNTIFS takes up to 127 pairs.
How many projects are not Completed?
=COUNTIF(B2:B11, "<>Completed")
Result: 5. But there are only four non-Completed statuses — two In Progress, two Pending. The fifth is the blank row: “<>” means “not equal to”, and a blank cell is not equal to “Completed”, so it gets counted. That is the trap. The fix is a second condition that excludes blanks:
=COUNTIFS(B2:B11, "<>Completed", B2:B11, "<>")
Result: 4. The “<>” on its own means “not blank”, so the blank row is excluded. Whenever you use “<>” to exclude a word, add the second “<>” so the blanks are not falsely counted.
| Function | Counts | On the Status column |
|---|---|---|
=COUNT(B2:B11) | Numbers only | 0 — there are no numbers |
=COUNTA(B2:B11) | Any non-blank cell | 9 — text and numbers, blanks excluded |
=COUNTIF(B2:B11, "*") | Cells with text | 9 |
=COUNTBLANK(B2:B11) | Blank cells | 1 |
COUNT is the wrong tool for text — it will always give 0. COUNTA counts everything non-blank, numbers included. COUNTIF with “*” is the one that counts text specifically, and it is the one that lets you add conditions.
| Mistake | What happens | Fix |
|---|---|---|
| You used COUNT on a text column | 0 — COUNT counts numbers only | Use =COUNTIF(range, "*") |
| You forgot the quotes around the text | #NAME? — Excel reads Completed as a name, not text | Put text criteria in quotes: "Completed" |
| You used “<>” to exclude a word | The blanks are counted too — 5 instead of 4 | Add a second condition: COUNTIFS(range, "<>Completed", range, "<>") |
| You assumed the match is case-sensitive | “completed” counts as “Completed” | That is usually fine; for case-sensitive, use SUMPRODUCT with EXACT |
| Your COUNTIFS ranges are different sizes | #VALUE! | Every criteria range must have the same number of rows |
| You compared against a cell and got 0 | The criterion needs joining: ">"&D1 for numbers, "*"&D1&"*" for text | Join with & instead of typing the cell inside the quotes |
| You counted a number stored as text | COUNTIF(“*”) counts it — numbers formatted as text are text | That is usually fine; to count only real numbers, use COUNT |
What is the formula to count cells with text in Excel? =COUNTIF(range, "*"). For example, =COUNTIF(B2:B11, "*") counts every cell in B2:B11 that contains text, and ignores blanks, numbers and dates.
How do I count cells that contain a specific word in Excel? =COUNTIF(range, "word") for an exact match, or =COUNTIF(range, "*word*") to count cells that contain the word anywhere. For example, =COUNTIF(B2:B11, "*Progress*") gives 2.
What is the difference between COUNTIF and COUNTIFS? COUNTIF takes one range and one condition. COUNTIFS takes one or more range/criteria pairs and counts only the rows where every pair matches (AND logic). Use COUNTIFS when your question has “and” in it.
Why does COUNT return 0 on my text column? COUNT counts numbers only. A column of text has no numbers, so the answer is 0. Use COUNTIF with “*” to count text, or COUNTA to count every non-blank cell.
How do I count cells that do not contain a word? =COUNTIFS(range, "<>word", range, "<>"). The first condition excludes the word, and the second excludes the blanks — without it, the blank cells are counted too.
Is COUNTIF case-sensitive? No. “apple”, “Apple” and “APPLE” all match. For a case-sensitive count, use =SUMPRODUCT(--EXACT(range, "Apple")).
How do I count cells with text in Google Sheets? The same way: COUNTIF and COUNTIFS have the same names and the same meaning in Google Sheets.
That is how to count cells with text in Excel: COUNT counts numbers only, so the function you want is COUNTIF — with an asterisk for any text, an exact word for a match, asterisks around a word for “contains”, and COUNTIFS when the question has a second condition. The one thing to remember is the blank trap: “not equal to” counts the blanks too, unless you add the second condition that excludes them. From here, the next counting to learn is the other half of the pair — counting numbers with conditions is the same two functions, and the SUM formula adds up the values instead of counting them — and the full learning order for the whole site is on the Excel Formulas hub.
Learn how to return blank instead of zero in Excel: =IF(A2-B2=0,"",A2-B2). Plus blank if no data, blank on error, and the ""...
=IF(A2-B2=0,"",A2-B2)COUNTIF counts cells that meet one condition, and COUNTIFS counts cells that meet several conditions. In this demo guide, you will learn...
=COUNTIF(range, criteria)IF lets Excel make decisions for you. In this demo guide, you will learn the syntax =IF(logical_test, value_if_true, value_if_false) and how IFS...
=IF(logical_test, value_if_true, value_if_false)