How COUNTIF & COUNTIFS works
COUNTIF walks down a column, checks each cell against your condition, and adds 1 to a tally for every match. The condition can be a value, a comparison wrapped in quotes, or a wildcard pattern.
COUNTIFS is the multi-condition cousin. You list pairs of (range, criteria) and Excel only counts rows where every condition is true. It's AND, never OR.
Both are read-only operations: they answer questions about your data, they never modify it. Pair them with SUMIF for total spend by category and COUNTIF for transaction count by category and you have a working dashboard.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| range | range | ✓ Required | The column or block of cells to check. Often a whole-column reference like B:B so newly added rows are included automatically. |
| criteria | any | ✓ Required | The condition. Literal value ("Active"), comparison wrapped in quotes (">100"), wildcard pattern ("J*"), or a cell reference (E2). Use & to splice in a cell value: ">"&E2. |
| Argument | Type | Required | Description |
|---|---|---|---|
| criteria_range1 | range | ✓ Required | The first column to check. |
| criteria1 | any | ✓ Required | The first condition (same shape as COUNTIF). |
| criteria_range2, criteria2, ... | pairs | ✗ Optional | Additional (range, criteria) pairs. Up to 127 pairs. All conditions must be true for a row to count (AND logic). |
COUNTIF basic: count active employees
You're an HR analyst. Leadership needs a single number: how many people on the roster are currently active. The Status column has values like Active, On Leave, Terminated. One COUNTIF turns the answer in.
=COUNTIF(B:B,"Active")- •
B:B-> the Status column - •
"Active"-> the value to count - •
Whole-column reference-> lets the formula keep working as new hires get added - •
Returns-> an integer: the count of matching rows
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Employee | Status | Active count | Result | ||
| 2 | Sarah Chen | Active | Active employees | 6 | ||
| 3 | James Miller | Active | ||||
| 4 | Maria Santos | On Leave | ||||
| 5 | David Brown | Active | ||||
| 6 | Emma Davis | Terminated | ||||
| 7 | Alex Kim | Active | ||||
| 8 | Carlos Gomez | On Leave | ||||
| 9 | Jenny Liu | Active | ||||
| 10 | Mark Reilly | Active | ||||
| 11 | Rachel Wood | Terminated |
COUNTIF with a comparison: how many sales over $1,000
Same pattern as SUMIF: wrap a comparison operator in quotes and COUNTIF tallies the matching numeric cells. Useful for any 'how many of X cleared the bar' question.
=COUNTIF(B:B,">1000")- •
B:B-> the column of sale amounts - •
">1000"-> the comparison, in quotes - •
Operators-> use >, <, >=, <=, =, <> all wrapped in quotes - •
Dynamic compare-> =COUNTIF(B:B,">"&E2) compares against the value in E2
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Order | Amount | Count > $1,000 | Result | ||
| 2 | PO-1001 | $450 | Sales over $1,000 | 5 | ||
| 3 | PO-1002 | $2,400 | ||||
| 4 | PO-1003 | $890 | ||||
| 5 | PO-1004 | $3,150 | ||||
| 6 | PO-1005 | $1,250 | ||||
| 7 | PO-1006 | $700 | ||||
| 8 | PO-1007 | $5,020 | ||||
| 9 | PO-1008 | $320 | ||||
| 10 | PO-1009 | $2,000 | ||||
| 11 | PO-1010 | $580 |
COUNTIF with wildcards: count by name pattern
The * wildcard matches any sequence of characters; ? matches exactly one. Useful for tallying entries by prefix, suffix, or partial match.
=COUNTIF(A:A,"J*")- •
A:A-> the Name column - •
"J*"-> matches any name starting with J - •
Other patterns-> "*Smith" matches anything ending in Smith. "*log*" matches any name containing log. - •
Numbers-> wildcards only work on text. Use comparison operators for numeric ranges.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Names starting with J | Result | ||
| 2 | Sarah Chen | Match "J*" | 4 | ||
| 3 | James Miller | ||||
| 4 | Maria Santos | ||||
| 5 | Jenny Liu | ||||
| 6 | David Brown | ||||
| 7 | Jacob Wright | ||||
| 8 | Emma Davis | ||||
| 9 | Jordan Hayes | ||||
| 10 | Carlos Gomez | ||||
| 11 | Mark Reilly |
COUNTIFS: count by department AND status
Real reports stack conditions. The CFO doesn't want all employees, she wants Active employees in Engineering. COUNTIFS handles that with a (range, criteria) pair for each condition - all must be true for a row to count.
=COUNTIFS(B:B,"Engineering",C:C,"Active")- •
B:B, "Engineering"-> first condition: Department equals Engineering - •
C:C, "Active"-> second condition: Status equals Active - •
Pair pattern-> every additional condition is another (range, criteria) pair - •
AND, not OR-> COUNTIFS only counts rows where every condition is true
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Employee | Department | Status | Active engineers | Result | ||
| 2 | Sarah Chen | Engineering | Active | Eng + Active | 4 | ||
| 3 | James Miller | Engineering | Active | ||||
| 4 | Maria Santos | Marketing | Active | ||||
| 5 | David Brown | Engineering | On Leave | ||||
| 6 | Emma Davis | Sales | Active | ||||
| 7 | Alex Kim | Engineering | Active | ||||
| 8 | Carlos Gomez | Operations | Active | ||||
| 9 | Jenny Liu | Marketing | Active | ||||
| 10 | Mark Reilly | Engineering | Terminated | ||||
| 11 | Rachel Wood | Engineering | Active |
COUNTIFS combining comparisons and literals
COUNTIFS pairs can mix types. Count orders that are both 'large enough' (over $1,000) and from a specific region. One pair uses a comparison, the other an exact match.
=COUNTIFS(A:A,"North",B:B,">1000")- •
A:A, "North"-> first pair: Region equals North - •
B:B, ">1000"-> second pair: Amount strictly greater than 1000 - •
Both must hold-> COUNTIFS counts rows where every pair matches - •
Order doesn't matter-> swap the pairs and you get the same answer
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Amount | North > $1,000 | Result | ||
| 2 | North | $450 | North + over $1k | 4 | ||
| 3 | North | $2,400 | ||||
| 4 | South | $890 | ||||
| 5 | North | $3,150 | ||||
| 6 | East | $5,020 | ||||
| 7 | North | $1,250 | ||||
| 8 | South | $2,000 | ||||
| 9 | North | $700 | ||||
| 10 | West | $4,000 | ||||
| 11 | North | $1,800 |
Where people go wrong
- Forgetting quotes around comparison operators
Writing =COUNTIF(B:B,>1000) without the quotes returns #NAME? because Excel can't parse a bare comparison operator. Quotes are mandatory for criteria with operators.
Fix: Always wrap operator-based criteria in quotes: ">1000", "<>0", "<="&E2 (with ampersand to splice cell values). - Wildcards on numeric data
Using =COUNTIF(B:B,"1*") to count numbers starting with 1 returns 0. Wildcards only work on text. Excel stores numbers as numbers, not as digit strings.
Fix: For numeric ranges use comparisons: =COUNTIF(B:B,">=10") AND =COUNTIF(B:B,"<20") combined, or COUNTIFS with both bounds. For text-formatted numbers, fix the format at the source. - Mismatched range sizes in COUNTIFS
Writing =COUNTIFS(B2:B100,'X',C2:C50,'Y') errors with #VALUE! because the two criteria ranges aren't the same shape. COUNTIFS requires every criteria range to have the same dimensions.
Fix: Use whole columns (B:B, C:C) when you can. They auto-grow with new data and there's no chance of mismatch. - Counting blanks vs empty strings
=COUNTIF(B:B,"") counts true blanks AND cells holding the empty string "". The two look identical on screen but Excel treats them differently for some operations.
Fix: Use COUNTBLANK for actual empty cells. For non-blank counts, use COUNTIF with criteria "<>"
Notes
- COUNTIF was introduced in Excel 2003. COUNTIFS arrived in Excel 2007. Both work in every modern version.
- Wildcards: * matches any sequence of characters, ? matches exactly one character. Escape with ~ to match a literal asterisk or question mark.
- Comparison operators in criteria must be wrapped in quotes: ">100", "<>0", ">="&E2 to splice a cell value.
- Both functions are case-insensitive: "active" matches "Active" and "ACTIVE".
- Empty criteria string ("") matches blank cells. Use "<>" to match every non-blank cell.
- When no rows match, both functions return 0 (not an error).
- COUNTIFS is AND logic - all conditions must hold. For OR logic, sum two COUNTIF results or use SUMPRODUCT.
Now prove it
Reading about COUNTIFS is one thing.
Writing one in front of an HR director who needs to know how many active engineers are eligible for the promotion review by lunch is completely different.
These exercises put you in real workplace scenarios where one well-structured COUNTIFS saves the morning.
Here's the thing about COUNTIFS.
You can read this page twice and still freeze when leadership drops a 30,000-row roster on your desk and asks how many people are eligible for the comp adjustment, before the 4pm board prep.
That gap, between knowing what COUNTIFS does and being able to write one cleanly under pressure, is exactly what CellSkill is built to close.
Not with more reading.
With practice on scenarios that look like your actual job.
Start practicing COUNTIFS for free →