COUNTIF with Criteria: How It Works in Excel

Formulas & functions · Updated November 23, 2026

The quick answer: use =COUNTIF(range, criteria) to count cells that meet one condition, and =COUNTIFS(criteria_range1, criteria1, ...) for multiple conditions. For example, =COUNTIF(A2:A20, "Paid") counts every cell in A2:A20 that contains exactly the word “Paid”.

What COUNTIF Actually Counts

COUNTIF counts only cells that match the criteria you give it. It works on numbers, text, dates, and even partial matches using wildcards. The function ignores empty cells and cells with errors unless your criteria specifically target them.

Key behavior to remember:

  • Text criteria are case-insensitive: "apple" matches “Apple”, “APPLE”, and “apple”.
  • Numbers are matched exactly unless you use comparison operators.
  • Wildcards * (any sequence) and ? (single character) work with text criteria.
  • Criteria that start with =, <, >, or <> must be enclosed in quotes.

How to Write the Criteria Argument

The criteria argument is the second parameter. It can be a number, text, expression, or cell reference. Here are the common forms:

  • Exact number: =COUNTIF(B2:B20, 100) counts cells equal to 100.
  • Comparison: =COUNTIF(B2:B20, ">=100") counts cells greater than or equal to 100.
  • Text: =COUNTIF(C2:C20, "Yes") counts cells that exactly equal “Yes”.
  • Cell reference: =COUNTIF(D2:D20, E1) uses the value in E1 as the criteria. For comparison with a cell reference, concatenate: =COUNTIF(D2:D20, ">"&E1).
  • Wildcard: =COUNTIF(A2:A20, "*East*") counts cells containing “East” anywhere.

For example, with sales amounts in B2:B20, =COUNTIF(B2:B20, ">500") returns the number of sales over 500. If you put 500 in cell E1, use =COUNTIF(B2:B20, ">"&E1).

Using COUNTIFS for Multiple Criteria

When you need to count rows that meet several conditions at once, use COUNTIFS. The syntax is =COUNTIFS(range1, criteria1, range2, criteria2, ...). All ranges must have the same number of rows and columns.

Example: with products in A2:A20 and regions in B2:B20, to count rows where product is “Widget” and region is “West”:

=COUNTIFS(A2:A20, "Widget", B2:B20, "West")

This returns the number of rows where both conditions are true. You can add up to 127 range/criteria pairs in Excel 365 and Excel 2021.

Common Problems and How to Fix Them

Many errors come from small mistakes in the criteria syntax:

  • Text not in quotes: =COUNTIF(A2:A20, Paid) returns a #NAME? error. Always quote text: "Paid".
  • Comparison operators not quoted: =COUNTIF(B2:B20, >100) is invalid. Use ">100".
  • Leading/trailing spaces: If your data has spaces, “Paid ” won’t match “Paid”. Use =COUNTIF(A2:A20, "*Paid*") to ignore surrounding spaces, or clean the data with TRIM.
  • Counting blank cells: To count truly empty cells, use =COUNTIF(A2:A20, ""). To count cells that are not empty, use =COUNTIF(A2:A20, "<>").
  • Dates as criteria: Enter dates with DATE function or a cell reference: =COUNTIF(C2:C20, DATE(2025,1,1)) counts cells equal to Jan 1, 2025. Using text like “1/1/2025” may be misinterpreted depending on regional settings.

If COUNTIF seems to ignore a cell, check for hidden characters or formatting that changes the displayed value vs. the actual value.

COUNTIF vs. Other Counting Functions

COUNTIF is not the only counting tool. Knowing when to use each saves time:

  • COUNT counts numeric cells only.
  • COUNTA counts non-empty cells (numbers, text, errors).
  • COUNTBLANK counts empty cells.
  • COUNTIF counts cells meeting one condition.
  • COUNTIFS counts cells meeting multiple conditions.
  • SUMPRODUCT can count with complex logic, e.g., =SUMPRODUCT((A2:A20="Widget")*(B2:B20="West")).

For example, to count all cells that contain any data, use =COUNTA(A2:A20). To count only numbers, use =COUNT(A2:A20).

Using COUNTIF with Wildcards and Partial Matches

Wildcards make COUNTIF flexible for text:

  • * matches any sequence of characters. "*apple*" matches “apple pie”, “pineapple”, and “apple”.
  • ? matches a single character. "sm?th" matches “smith” and “smyth”.
  • To count cells that start with “A”: =COUNTIF(A2:A20, "A*").
  • To count cells that end with “ed”: =COUNTIF(A2:A20, "*ed").

Wildcards only work with text criteria, not with numbers. If you need to count numbers that start with a digit, use SUMPRODUCT with TEXT, but that’s rare.

COUNTIF with Cell References and Dynamic Ranges

Using a cell reference for criteria makes your formulas easier to update. For example, with a threshold in E1:

=COUNTIF(B2:B20, ">"&E1)

If you change E1 from 500 to 1000, the formula recalculates automatically. To use a range that grows as you add data, consider a structured table reference or a dynamic named range. For instance, if your data is in a table named Table1, use =COUNTIF(Table1[Sales], ">500").

Frequently Asked Questions

Can COUNTIF count cells that contain a specific word anywhere? Yes, use wildcards: =COUNTIF(A2:A20, "*word*"). This counts any cell that has “word” anywhere in the text, including as part of another word.

Why does COUNTIF return 0 when I know there are matches? Often it’s a data type mismatch. If your criteria is text but the cells are numbers stored as text, or vice versa, they won’t match. Check for leading apostrophes, spaces, or number formatting. Try using =COUNTIF(A2:A20, "*"&E1&"*") if E1 contains the text you’re looking for.

How do I count cells that are not equal to something? Use =COUNTIF(A2:A20, "<>Paid") to count cells not equal to “Paid”. For numbers, =COUNTIF(B2:B20, "<>100") counts cells not equal to 100. Note that this also counts empty cells, so combine with COUNTA if needed.

Can I use COUNTIF with dates? Yes. Use a date serial number or the DATE function: =COUNTIF(C2:C20, DATE(2025,1,1)) counts cells equal to Jan 1, 2025. To count dates after a certain date, use =COUNTIF(C2:C20, ">"&DATE(2025,1,1)).

What is the difference between COUNTIF and COUNTIFS? COUNTIF handles one condition; COUNTIFS handles multiple conditions across multiple ranges. For a single condition, both work, but COUNTIF is simpler. For multiple conditions, you must use COUNTIFS.

Does COUNTIF work in Google Sheets? Yes, the syntax is identical. However, in Google Sheets you can also use QUERY or FILTER for more complex counting. The wildcard behavior is the same.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.