Use =COUNTIF(range, criteria) to count how many cells in a range meet a condition, for example =COUNTIF(B2:B8,">100").
=COUNTIF(A2:A8,"Pens")
You often need a quick tally from a list: how many orders came from one region, how many prices are above a limit, or how many times a name appears. COUNTIF does that without sorting or filtering.
Step by step
- Click the cell where you want the count to appear.
- Type
=COUNTIF(and then select the range you want to check, for exampleB2:B8. - Type a comma, then the criteria in quotes if it is text or a comparison, like
"Pens"or">100". - Close the bracket and press Enter. The cell shows the count.
- To reuse the formula, drag the fill handle down or copy it; use absolute references like
$B$2:$B$8if the range should stay fixed.
Try it here
Examples
1 Count cells equal to a text value
Counts how many times the word Pens appears in the Item column. The criteria is text, so it goes in double quotes.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | Price | |||
| 2 | Pens | 4 | 4 | ||
| 3 | Pencils | 2 | |||
| 4 | Pens | 5 | |||
| 5 | Eraser | 1 | |||
| 6 | Pens | 3 | |||
| 7 | Ruler | 2 | |||
| 8 | Pens | 6 | |||
| 9 |
=COUNTIF(A2:A8,"Pens")2 Count numbers greater than a value
Counts how many prices are above 3. The comparison operator is inside the quotes, and the number can be inside or outside the quotes.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | Price | |||
| 2 | Pens | 4 | 3 | ||
| 3 | Pencils | 2 | |||
| 4 | Pens | 5 | |||
| 5 | Eraser | 1 | |||
| 6 | Pens | 3 | |||
| 7 | Ruler | 2 | |||
| 8 | Pens | 6 | |||
| 9 |
=COUNTIF(B2:B8,">3")3 Count cells that are not empty
Counts how many cells in the Item column contain something. The criteria "" means not equal to empty.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | Price | |||
| 2 | Pens | 4 | 7 | ||
| 3 | Pencils | 2 | |||
| 4 | Pens | 5 | |||
| 5 | Eraser | 1 | |||
| 6 | Pens | 3 | |||
| 7 | Ruler | 2 | |||
| 8 | Pens | 6 | |||
| 9 |
=COUNTIF(A2:A8,"<>")Other ways to do it
| Formula | Use it when |
|---|---|
=COUNTIFS(A2:A8,"Pens",B2:B8,">3") | You need to count rows that meet two or more conditions at once. |
=SUMPRODUCT(--(A2:A8="Pens")) | You prefer a formula that works in older Excel versions without COUNTIFS, or need to combine with other array logic. |
Practise it
Free exercises with instant feedback. No sign-up needed.
Common mistakes
- The criteria is not in quotes, so Excel shows an error or looks for a named range. Put text and comparisons in double quotes, like
"Pens"or">100". Numbers can be unquoted if there is no operator. - The range is not locked, so copying the formula down shifts it and counts the wrong cells. Use absolute references such as
$A$2:$A$8when the range should stay the same. - Wildcards behave unexpectedly:
*matches any text, so"Pen*"also counts Pencils. Use exact text or add more characters, and remember?matches one character.
Questions people also ask
Can COUNTIF count dates?
Yes. Use a date in quotes or a cell reference, for example =COUNTIF(A2:A8,">2024-01-01") or =COUNTIF(A2:A8,D1) where D1 holds the date.
Why does COUNTIF return 0 when I can see matches?
Check for extra spaces or numbers stored as text. Use TRIM or clean the data, and make sure the criteria type matches the cell values.
What is the difference between COUNTIF and COUNTIFS?
COUNTIF handles one condition. COUNTIFS handles multiple conditions and uses the same criteria style for each range.
Functions used
Every formula on this page was checked by SheetSkill’s spreadsheet engine. All how-to guides