Count cells that match one condition
COUNTIF counts the cells in a range that meet a condition. The syntax is:
=COUNTIF(range, criteria)
For example, to count how many rows in column C say “Late”:
=COUNTIF(C2:C50, "Late")
Criteria can be text, a number, an expression or a cell reference. Text needs quotation marks when you type it into the formula, as in the example above.
Count numbers above or below a value
Comparison operators work the same way as they do in SUMIF. To count the cells in column B that are 100 or more:
=COUNTIF(B2:B50, ">=100")
To count the cells that equal a value stored in a cell, such as E1, use =COUNTIF(B2:B50, E1).
Use wildcards for partial matches
An asterisk (*) matches any run of characters, and a question mark (?) matches exactly one character. To count every cell in column A that contains “tea”, whether it reads “Green tea” or “Tea bags”:
=COUNTIF(A2:A50, "*tea*")
Matching is not case-sensitive, so “Yes” and “yes” are counted together.
Count dates
Join a comparison operator and a DATE value with an ampersand. To count the rows in column D dated on or after January 1, 2026:
=COUNTIF(D2:D50, ">="&DATE(2026,1,1))
Count blank and non-blank cells
=COUNTIF(C2:C50, "")counts cells that are empty, as well as cells holding a formula that returns an empty string.- For cells that are not empty, COUNTA is often the simpler choice. How to sum and count in excel covers it alongside the other counting functions.
Why COUNTIF returns 0
- Typos and extra spaces. “Late “ with a trailing space won’t match “Late”. Check the text in the cells against your criteria.
- Forgotten quotation marks.
=COUNTIF(C2:C50, Late)returns #NAME?, because Excel reads Late as a name rather than as text. - The wrong range. Make sure the range covers the rows you expect, and that it isn’t on another sheet by mistake.
Count with two or more conditions
COUNTIF handles one condition. When a count depends on a second test, such as status and owner, use COUNTIFS, which is covered in countifs with two conditions in excel.