What COUNTIF does
COUNTIF counts how many cells in a range meet one condition. =COUNTIF(B2:B9,"North") counts the cells in B2:B9 that say North, and =COUNTIF(C2:C9,">250") counts the amounts over 250. It answers questions like how many orders came from the North or how many invoices are over the approval limit.
The condition can come from a cell, so the same formula keeps working in a weekly report when someone changes the limit or the region.
COUNTIF checks each cell on its own. Text has to match the whole cell, and capitals don’t matter: “north” counts the cells that say “North”.
Syntax
rangeRequired- The cells to check, such as
B2:B9. COUNTIF looks at each one and counts it when it meets the condition. criteriaRequired- The condition. Text to match goes in quotation marks (
"North"), and so does a comparison (">250"). A plain number or a cell needs none:100orB1. To compare with a cell, join the operator to it with &:">"&B1.
Example: count the orders from one region
Each order’s region is in column B. To count the North orders:
To count another region, change the text in quotation marks, or put the region in a cell of its own and use that cell as the condition.
Example: count the claims over a limit kept in a cell
Expense claims over the approval limit need a manager’s sign-off. The limit, 250, is in B1, so it can change without anyone editing the formula.
The & joins the operator to the value in B1, so the condition reads “>250”. Raise the limit to 300 and the count drops to 2.
Not blank, not equal to and other conditions
Text and comparisons go in quotation marks, with the operator inside them. The condition comes second, after the range:
| Condition | Counts the cells that |
|---|---|
"North" | say North, in any mix of capitals |
"<>North" | say anything else, empty cells included |
"<>" | aren’t empty |
"" | are empty |
">0" | hold a number greater than 0 |
">="&F1 | hold a number at least as big as the one in F1 |
In a full formula, =COUNTIF(B2:B9,"<>") counts the filled-in cells in B2:B9. When you need no condition at all, COUNTA counts every cell that isn’t empty.
COUNTIF vs COUNTIFS
COUNTIF takes one range and one condition. COUNTIFS takes pairs of range and condition, up to 127, and counts a row only when it passes every test, such as North orders that were late. With one pair the two give the same count: on the orders above, =COUNTIF(B2:B9,"North") and =COUNTIFS(B2:B9,"North") both return 4. To add up the amounts on the matching rows, use SUMIF.
Common mistakes
- A comparison goes in quotation marks inside COUNTIF:
">250". Without them,=COUNTIF(B2:B8,>250)isn’t a formula Excel accepts. ">B1"compares with the letters B1, so it usually counts 0. To compare with the value in B1, join the cell on with &:">"&B1.- “North ” with a trailing space doesn’t match “North”. Data pasted from other systems often carries spaces like that, and TRIM removes them.
"<>North"counts every cell that isn’t North, empty cells included, so make the range stop where the data stops.- COUNTIF takes one condition. For “North and late”, use COUNTIFS.
Frequently asked questions
Is COUNTIF case-sensitive?
No. “north”, “North” and “NORTH” all match the same cells. When capitals matter, a formula with EXACT can tell them apart.
How do I count cells that contain specific text?
Use wildcards: =COUNTIF(B2:B9,"*east*") counts every cell that contains “east” anywhere. An asterisk stands for any characters and a question mark for exactly one, so "A??" counts three-character entries that start with A. Put a tilde before a real asterisk or question mark.
Why is my COUNTIF returning 0?
The condition matches no cell exactly. Look for trailing spaces or typos in the data, and check that no cell is written inside the quotes: ">B1" compares with the letters B1, while ">"&B1 uses the value in B1.
How do I count cells that say one thing or another?
Add two COUNTIFs together: =COUNTIF(B2:B9,"North")+COUNTIF(B2:B9,"South") counts the cells that say North or South.