Count Cells With Text in Excel — COUNTIF and COUNTIFS Explained
Learn how to count cells with text in Excel: COUNTIF with "*", exact matches, wildcards, COUNTIFS for two conditions, and the blank-cell...
Read Guide →Your report is full of zeros — in rows where nothing has been entered yet, in a subtraction that came out even, in a division by an empty cell. The zeros are not wrong, exactly, but they make the sheet look unfinished, and they hide the rows that actually have data. The fix is two double quotes with nothing between them, "", inside an IF formula: when the answer would be zero, Excel shows a blank cell instead. This guide gives you that formula first, works it through on three real cases — zero, no data yet, and an error — and then tells you the one thing the other guides bury: a cell that looks blank because of "" is not really empty, and the next formula you write needs to know that.
Quick takeaway: two double quotes, "", is the whole trick.
=IF(A2-B2=0,"",A2-B2)=IF(A2="","",A2*0.05)=IFERROR(A2/B2,"")"" looks blank but is NOT empty — ISBLANK returns FALSE on it.=B2="", not ISBLANK.
=IF(A2-B2=0, "", A2-B2)
A formula cannot truly delete a cell’s contents. It can only make the cell appear empty by returning an empty string. That distinction matters, and it gets its own section below.
Inventory: stock received in A, stock sold in B, remaining in C with =IF(A2-B2=0,"",A2-B2):
| Stock Received (A) | Stock Sold (B) | Remaining (C) |
|---|---|---|
| 100 | 100 | blank |
| 80 | 50 | 30 |
| 60 | 60 | blank |
Check it: 100 − 100 = 0, so C2 shows blank. 80 − 50 = 30, so C3 shows 30. 60 − 60 = 0, so C4 shows blank. The zeros are gone, and the rows with stock left stand out.
The same pattern works for profit: selling price in D, buying price in C, profit =IF((D2-C2)=0,"",(D2-C2)). Sell for 500, bought for 500 → blank. Sell for 600, bought for 500 → 100.
This is the most common use. A commission column that should stay blank until a sales figure is typed in:
=IF(A2>0, A2*0.05, "")
| Sales (A) | Commission 5% (B) |
|---|---|
| 1000 | 50 |
| (blank) | blank |
| 500 | 25 |
| 0 | blank |
| 2000 | 100 |
Check it: 1000 × 5% = 50. The blank row stays blank — no 0 sitting in it. 500 × 5% = 25. A typed 0 also gives blank, because 0 is not greater than 0. And 2000 × 5% = 100.
The other way to write the same test: =IF(A2="","",A2*0.05) — if A2 is empty, return blank, otherwise calculate. Or with ISBLANK: =IF(ISBLANK(A2),"",A2*0.05). All three do the same job; pick the one you find easiest to read.
Dividing by an empty cell gives #DIV/0!. Wrap the formula in IFERROR:
=IFERROR(A2/B2, "")
100 / 4 = 25. 100 / 0, or 100 / (an empty cell), gives blank instead of #DIV/0!. The error is gone, and so is the ugly message in the report.
One warning: IFERROR hides every error, including real mistakes in your formula — a wrong reference, a #NAME? from a typo. If you only want to hide #N/A, use IFNA instead: =IFNA(VLOOKUP(...),""). IFNA catches only #N/A and lets every other error show, so a real mistake is still visible. The same advice appears in the XLOOKUP vs VLOOKUP guide.
The same IF pattern handles a negative result. Profit that should never show as a loss:
=IF((D2-C2)<0, "", D2-C2)
Sell for 400, bought for 500 → −100 → blank. Sell for 600, bought for 500 → 100.
And the reverse direction, which the group keywords also ask for — show 0 instead of a negative number, so a balance never goes below zero:
=MAX(0, A2-B2)
MAX returns the larger of 0 and the answer. 80 − 50 = 30, so MAX gives 30. 40 − 60 = −20, so MAX gives 0. No IF needed, and the cell holds a real number, not text.
And the other reverse — 0 instead of blank, when a downstream formula needs a number:
=IF(A2="", 0, A2)
If A2 is empty, the cell holds 0. If A2 has a value, it holds that value.
This is the section that saves you from the next mistake. A cell holding "" looks empty. It is not empty. It holds a text string with zero characters, and Excel treats it as text.
Test it yourself. B2 holds =IF(A2="","",A2*0.05) and A2 is blank, so B2 looks empty. Now test it:
| Test | Result | Why |
|---|---|---|
=ISBLANK(B2) | FALSE | ISBLANK only returns TRUE for a truly empty cell — one with no formula and no value |
=B2="" | TRUE | This is the correct test for a “” cell |
=COUNTA(B2:B6) | Counts the “” cells | COUNTA counts every non-empty cell, and “” counts as non-empty |
=SUM(B2:B6) | Correct total | SUM ignores text, so “” does not change a sum |
=AVERAGE(B2:B6) | Correct average | AVERAGE ignores text too |
So: SUM and AVERAGE are safe with “” cells. COUNTA is not — a range with 3 numbers and 2 “” cells gives COUNTA = 5, not 3. And any formula that tests ISBLANK on a “” cell gets FALSE. If you need to test for it, use =B2="".
If you need the cell to be truly empty, a formula cannot do it — only deleting the formula, or clearing the cell, makes it truly empty. The custom format below hides zeros without putting any text in the cell at all.
If you do not want to change any formula, you can hide the zeros by formatting. Select the cells, right-click → Format Cells → Custom, and type:
0;-0;;@
A number format has four sections, separated by semicolons: positive; negative; zero; text. 0;-0;;@ shows positive numbers normally, negative numbers normally, shows nothing for zero, and shows text normally. The zeros disappear, the values are still there, and the cells are still truly numbers — SUM, AVERAGE, COUNTA and ISBLANK all behave exactly as before.
Do not use ;;; for this. Three semicolons with nothing between them hides everything — numbers, text, all of it. The 0;-0;;@ version hides only the zeros.
Use the format when the whole column should never show a zero. Use the IF formula when only some cells should be blank, or when the blank depends on a condition.
| Mistake | What happens | Fix |
|---|---|---|
You typed "" with a space inside (" ") | The cell shows a space, not a blank — and it is not empty either | Two quotes, nothing between them: "" |
You used single quotes ('') | Excel does not recognise them — the formula breaks | Double quotes only: "" |
| You tested a “” cell with ISBLANK | FALSE — ISBLANK only works on truly empty cells | Test with =B2="" |
| Your COUNTA is too high after adding blanks | COUNTA counts “” cells as non-empty | Use COUNT for numbers, or COUNTIF with "<>" for text |
| You used IFERROR to hide #DIV/0! | It hides real mistakes too | Use IFNA for #N/A only, or test the divisor first: =IF(B2=0,"",A2/B2) |
You used ;;; as the custom format | Everything is hidden, not just the zeros | Use 0;-0;;@ to hide only zeros |
| You wanted a truly empty cell | A formula cannot make one — “” is text | Delete the formula, or clear the cell |
How do I return blank instead of zero in Excel? Use =IF(A2-B2=0,"",A2-B2). If the answer is zero, the cell shows blank. Otherwise it shows the answer.
How do I make a formula return blank if there is no data? Use =IF(A2="","",A2*0.05). If A2 is empty, the cell stays blank until you type a number.
How do I return blank instead of #DIV/0!? Use =IFERROR(A2/B2,""). Or test the divisor first: =IF(B2=0,"",A2/B2).
Is a cell with “” really empty? No. It holds an empty text string. ISBLANK returns FALSE on it, and COUNTA counts it. Test it with =B2="" instead.
Why is my COUNTA wrong after adding blanks? Because COUNTA counts “” cells. Use COUNT for numbers, or COUNTIF with "<>" for text.
How do I hide zeros without changing the formula? Select the cells, Format Cells → Custom, type 0;-0;;@. The zeros disappear and the values stay as real numbers.
How do I show 0 instead of a negative number? Use =MAX(0,A2-B2). The answer never goes below zero.
How do I show 0 instead of blank? Use =IF(A2="",0,A2). An empty A2 gives 0; a value in A2 gives that value.
That is the whole method: two double quotes inside an IF, and the cell shows blank instead of zero, instead of an error, or until the data arrives. It works for inventory, commission, profit and division, and the only case that needs extra care is the one the trap section covers — a blank-looking cell is text, not empty, so test it with ="" and count it with COUNT, not COUNTA. When you would rather hide the zeros without touching any formula, the custom format 0;-0;;@ does it in one step. Try it on your own sheet now, with the commission table above, and when the condition itself is the point — when a cell should show one thing if a test passes and another if it fails — the next guide to read is the absolute reference guide, which is the other half of writing formulas that survive being copied down a column.
Learn how to count cells with text in Excel: COUNTIF with "*", exact matches, wildcards, COUNTIFS for two conditions, and the blank-cell...
Read Guide →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)