How to use COUNTIF in Excel
COUNTIF counts the cells that meet a condition — how many orders from a city, how many scores above 90, how many "Yes" answers.
Syntax
=COUNTIF(range, criteria)
range | The cells to check. |
criteria | The condition: value, cell, comparison (">90") or wildcard ("A*"). |
Examples
=COUNTIF(A2:A100, "Sofia")Orders from Sofia.=COUNTIF(B2:B100, ">=90")Scores of 90 or more.=COUNTIF(A2:A100, A2)>1TRUE if A2 is a duplicate.=COUNTIF(C2:C100, "<>")Non-empty cells.Find duplicates with COUNTIF
Count how many times each value appears in the whole column: anything above 1 is a duplicate. A growing range (only the start locked) counts the rows so far, so it marks only the second and later copies. More methods in how to find unique values.
=COUNTIF($A$2:$A$100, A2)>1TRUE for every value that appears more than once.=COUNTIF($A$2:A2, A2)>1TRUE only for the repeats, so the first copy stays FALSE.Count between two numbers or dates
COUNTIF takes one condition, so for "between" use COUNTIFS with two conditions on the same range.
=COUNTIFS(B2:B100, ">=50", B2:B100, "<=100")Scores from 50 to 100.=COUNTIFS(D2:D100, ">="&DATE(2026,1,1), D2:D100, "<"&DATE(2026,2,1))Orders in January 2026.Count text, partial matches and blanks
Wildcards make COUNTIF useful on messy text: * is any number of characters.
=COUNTIF(A2:A100, "*")Cells that contain any text.=COUNTIF(A2:A100, "*smith*")Cells that contain "smith" anywhere.=COUNTIF(A2:A100, "")Empty cells.Common mistakes
- Comparison with a cell
- Write
">"&E2, not">E2". - Case doesn't matter
- COUNTIF treats "sofia" and "Sofia" as the same.
- Long numbers
- Numbers longer than 15 digits (card numbers, IDs) can match wrongly — store them as text.
Frequently asked questions
How do I count cells that contain text?
=COUNTIF(A2:A100, "*") counts every cell with text in it. Numbers and empty cells aren't counted.
Can COUNTIF count with two conditions?
No, but COUNTIFS can: =COUNTIFS(A2:A100, "Sofia", C2:C100, ">500") counts orders from Sofia above 500.
How do I count unique values?
=SUMPRODUCT(1/COUNTIF(A2:A100, A2:A100)) counts the different values in a list with no empty cells. In Excel 365, =COUNTA(UNIQUE(A2:A100)) does the same.
Is COUNTIF case-sensitive?
No. "Yes", "yes" and "YES" all count as the same value.
Available in: All versions of Excel, Excel for the web, Google Sheets