Counts how many cells in a range meet a single condition.
COUNTIF answers 'how many?' where SUM answers 'how much?'. How many orders came from the North region, how many amounts were over £1,000, how many cells are still blank. It takes a range and a condition and returns a count of the cells that match.
It is also the fastest way to find duplicates. Point COUNTIF at a column and ask how many times the current row's value appears in it; anything greater than 1 is a repeat. That one formula, used in conditional formatting, is how most people highlight duplicate entries.
Like SUMIF, it handles one condition only. COUNTIFS takes several, and follows the same pattern of range-and-criteria pairs.
=COUNTIF(range, criteria)rangecriteriaHeaders in row 1, data in A2:D6.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Region | Rep | Category | Amount |
| 2 | North | Alice | Hardware | 1240 |
| 3 | South | Bruno | Software | 385 |
| 4 | North | Chen | Hardware | 2100 |
| 5 | South | Alice | Software | 940 |
| 6 | North | Bruno | Software | 156 |
=COUNTIF(A2:A6, "North")Result: 3
Three rows are in the North region.
=COUNTIF(D2:D6, ">1000")Result: 2
Comparisons go inside quotes. Two amounts are above 1000.
=COUNTIF(C2:C6, "<>Hardware")Result: 3
<> means 'not equal to', so this counts the Software rows.
=COUNTIF($B$2:$B$6, B2)Result: 2
The duplicate check. Alice appears twice, so this returns 2 — filled down the column, anything above 1 is a repeated value.
Reading about a formula is not the same as writing one. Open this function's exercise and type it into a real grid — you get instant feedback on exactly which cell is wrong and why.
Why it happens: Trailing spaces, or numbers stored as text so a numeric comparison never matches.
How to fix it: Clean with TRIM and confirm the column is genuinely numeric. Text numbers align left by default, which is the quickest visual check.
Why it happens: COUNTIF is not case sensitive and treats * and ? as wildcards, so a criteria string containing them matches more than intended.
How to fix it: Escape a literal asterisk or question mark with a tilde: "~*". For case-sensitive counting use SUMPRODUCT with EXACT.
Why it happens: The range points at a workbook that is currently closed.
How to fix it: COUNTIF cannot read closed workbooks. Open the source file, or copy the data into the same one.
Wrap the text in asterisks: =COUNTIF(A2:A100, "*urgent*") counts every cell with "urgent" somewhere inside it, rather than cells equal to it.
COUNT counts cells containing numbers. COUNTA counts cells that are not empty, whatever they hold. COUNTIF counts cells meeting a condition you specify. If you want a plain total of filled rows, COUNTA is the one you want.
Not directly. The classic approach is =SUMPRODUCT(1/COUNTIF(range, range)), which counts each distinct value once. If your Excel has dynamic arrays, =COUNTA(UNIQUE(range)) is far clearer.
Longer reads where this function does real work in a real sheet.