Sums and Counts

How to Use the COUNTIF Function in Excel

Learn how to use COUNTIF in Excel to count cells that match a condition, including numbers, dates, wildcards, blank cells and fixes for zero results.

On this page
  1. Count cells that match one condition
  2. Count numbers above or below a value
  3. Use wildcards for partial matches
  4. Count dates
  5. Count blank and non-blank cells
  6. Why COUNTIF returns 0
  7. Count with two or more conditions

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.

The complete guide to sums and counts

How to Sum and Count in Excel
Read the guide

Keep exploring

Guides from other topics

All topics →

How to Look Up Data in Excel

How lookups work in Excel, with VLOOKUP, XLOOKUP and INDEX with MATCH, how to set up your data, and how to choose the right function for the job.

Lookups 3 min read