COUNTIF Function
Counts the cells that meet one condition.
Category
Statistical
Available in
All versions, Microsoft 365
Returns
A whole number
Overview
COUNTIF counts the cells in a range that match a condition — a value, a comparison or a pattern.
Criteria can be a value ("North", 50000), a comparison in quotes (">=50000", "<>North"), a comparison joined to a cell (">="&F2), or a pattern with wildcards — * for any characters, ? for one character ("A*", "?d"). Text matching ignores upper/lower case.
Syntax
Arguments
| Argument | Required? | What it does |
|---|---|---|
| range | Yes | The cells to count. |
| criteria | Yes | The condition, such as "North", ">=50000" or "A*". |
Examples
Example 1 — Counting reps
Text, a comparison, "not equal" and a wildcard.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Rep | Region | Sales | Measure | Result |
| 2 | Ana | North | 62000 | North | 3 |
| 3 | Ben | South | 48500 | 50k or more | 4 |
| 4 | Cy | North | 50000 | Not North | 4 |
| 5 | Di | East | 71250 | Name has an a | 2 |
| 6 | Ed | South | 39800 | ||
| 7 | Fay | North | 55400 | ||
| 8 | Gus | East | 48500 |
"*a*" matches Ana and Fay — matching ignores case.
Example 2 — Flag duplicates
Count how often each value appears in its own column; more than 1 means a duplicate.
TRUE for Ben and Gus, who both sold 48,500.
Common mistakes
- Comparison without quotes. =COUNTIF(C2:C8,>50000) is an error. Write ">50000" in quotes, or ">"&F2 to use a cell.
- Putting the cell inside the quotes. ">F2" compares with the text "F2". Join the cell instead: ">"&F2.
- Long numbers. COUNTIF compares numbers, so IDs longer than 15 digits (like card numbers) that differ only at the end are counted as equal.
Notes
- "" counts empty cells (and formulas returning ""); "<>" counts non-empty ones.
- To match a real * or ?, put a tilde in front: "~*".
- Related functions: COUNTIFS, SUMIF, AVERAGEIF, COUNTA.

Author
Kyle Stott
Certified Microsoft Excel Expert
Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.