Google Sheets COUNTIF: Count Cells That Match

How-to basics · Updated November 22, 2026

The quickest way to count cells in Google Sheets that meet a condition is the COUNTIF function. Its syntax is =COUNTIF(range, criterion), and it returns the number of cells in that range that match the criterion. For example, =COUNTIF(A2:A20, "Yes") counts how many cells in A2:A20 contain the exact text “Yes”.

What COUNTIF Does and When to Use It

COUNTIF is one of the most-used functions in Google Sheets because it answers a simple but frequent question: “How many of these cells meet this rule?” It works on numbers, text, dates, and even blank or non-blank cells. You might use it to count how many sales were above $500, how many students passed a test, or how many times a certain product name appears in a list.

The function takes two arguments:

  • range – the group of cells to examine (e.g., A2:A100).
  • criterion – the condition that decides whether a cell is counted. This can be a number, text, a cell reference, or a comparison expression like ">10".

COUNTIF is a single-condition counter. If you need to count cells that meet multiple conditions at once (for example, “sales above $500 in the West region”), you need COUNTIFS, which accepts multiple range/criterion pairs. For most simple counting tasks, COUNTIF is enough.

How to Write the Criterion Correctly

The criterion is the part that trips up most users. It must be a string, so when you use a comparison operator, you put it in double quotes. Here are the common patterns:

  • Exact text match: =COUNTIF(B2:B20, "Apples") – counts cells that equal “Apples” (case-insensitive by default).
  • Number match: =COUNTIF(C2:C20, 10) – counts cells equal to 10.
  • Greater than: =COUNTIF(C2:C20, ">10") – counts cells greater than 10.
  • Not equal to: =COUNTIF(C2:C20, "<>0") – counts cells not equal to 0.
  • Contains text (wildcard): =COUNTIF(A2:A20, "*apple*") – counts cells that contain the substring “apple” anywhere.
  • Starts with: =COUNTIF(A2:A20, "app*") – counts cells that start with “app”.
  • Cell reference as criterion: =COUNTIF(C2:C20, ">"&D1) – counts cells greater than the value in D1. The ampersand (&) joins the operator and the reference.

Note that COUNTIF is case-insensitive: “apple” and “APPLE” are treated the same. If you need case-sensitive counting, you must use a helper column with EXACT or use FILTER with EXACT.

COUNTIF with Dates and Blank Cells

Dates are stored as numbers in Google Sheets, so you can compare them directly if you use the DATE function or a cell reference. For example, to count orders after January 1, 2024:

=COUNTIF(D2:D100, ">"&DATE(2024,1,1))

This counts all cells in D2:D100 that are greater than the date value for January 1, 2024. If you type a date directly in the criterion, like ">1/1/2024", Sheets may misinterpret it as a string, so using DATE() is safer.

To count blank cells, use =COUNTIF(A2:A20, ""). To count non-blank cells, use =COUNTIF(A2:A20, "<>"). Note that "<>" counts cells that are not empty, but it also counts cells containing formulas that return an empty string (“”) as non-blank. If you need to exclude those, use COUNTA for non-empty values or COUNTBLANK for truly empty cells.

Common Mistakes and How to Avoid Them

Several errors are extremely common when using COUNTIF:

  • Forgetting quotes around comparison operators. =COUNTIF(A2:A20, >10) is invalid. It must be ">10".
  • Using a comma as a decimal separator. In some locales, you must use a semicolon (;) as the argument separator. If you get a formula parse error, check your spreadsheet’s locale settings (File > Settings).
  • Mismatched ranges in COUNTIFS. In COUNTIFS, all ranges must have the same number of rows and columns, or you’ll get a #VALUE! error.
  • Counting text that looks like numbers. If a cell contains the text “10” (with an apostrophe before it), COUNTIF will count it as text, not as the number 10. Use VALUE if needed.
  • Wildcards being literal. If you want to count an actual asterisk or question mark, you must escape it with a tilde (~). For example, =COUNTIF(A2:A20, "~*") counts cells that contain a literal asterisk.

COUNTIF vs. COUNTIFS vs. Other Count Functions

Google Sheets offers several counting functions, and choosing the right one saves time:

  • COUNT – counts numeric values only. =COUNT(A2:A20) ignores text and blanks.
  • COUNTA – counts all non-empty cells, including text and numbers. =COUNTA(A2:A20).
  • COUNTBLANK – counts empty cells. =COUNTBLANK(A2:A20).
  • COUNTIF – counts cells that meet one condition.
  • COUNTIFS – counts cells that meet multiple conditions across multiple ranges. Example: =COUNTIFS(A2:A20, "West", B2:B20, ">500") counts rows where region is “West” and sales are above 500.
  • SUMPRODUCT – a more flexible alternative for complex conditions, especially when you need to count based on multiple criteria in the same range or use OR logic. For instance, =SUMPRODUCT((A2:A20="Red")+(A2:A20="Blue")) counts cells that are either “Red” or “Blue”.

For most everyday tasks, COUNTIF is the simplest. When you need multiple conditions, COUNTIFS is usually clearer than SUMPRODUCT. However, SUMPRODUCT can handle OR logic natively, which COUNTIFS cannot do directly.

Real-World Example: Sales Data

Suppose you have a spreadsheet with orders. Column A has the region (East, West, North, South), Column B has the sales amount, and Column C has the order date. Here are some practical formulas:

  • Count orders from the East region: =COUNTIF(A2:A100, "East")
  • Count orders over $1000: =COUNTIF(B2:B100, ">1000")
  • Count orders in January 2024: =COUNTIF(C2:C100, ">="&DATE(2024,1,1)) - COUNTIF(C2:C100, ">="&DATE(2024,2,1)) – this subtracts orders after January to get only January orders. Alternatively, use COUNTIFS: =COUNTIFS(C2:C100, ">="&DATE(2024,1,1), C2:C100, "<"&DATE(2024,2,1))

These formulas return counts based on your actual data. Always test with a small sample to verify the logic.

Frequently Asked Questions

Can COUNTIF count cells with multiple conditions? No, COUNTIF only handles one condition. Use COUNTIFS for multiple conditions. For example, =COUNTIFS(A2:A20, "West", B2:B20, ">500").

How do I count cells that contain a specific word? Use wildcards: =COUNTIF(A2:A20, "*word*"). This counts cells that contain "word" anywhere. Remember it's case-insensitive.

Why is my COUNTIF returning 0? Check for leading/trailing spaces in your data, or the criterion might be a number stored as text. Use TRIM on your data or use VALUE in the criterion. Also ensure the range is correct and doesn't include merged cells that can cause issues.

Can I use COUNTIF across different sheets? Yes, you can reference another sheet by name: =COUNTIF(Sheet2!A2:A20, "Yes"). If the sheet name has spaces, put it in single quotes: =COUNTIF('My Sheet'!A2:A20, "Yes").

Does COUNTIF count blank cells? Only if you specify the criterion as "". By default, COUNTIF ignores blank cells. To count blanks, use =COUNTIF(A2:A20, "") or COUNTBLANK.

Is there a way to count unique values? COUNTIF alone cannot count unique values. Use COUNTUNIQUE to count unique entries in a range: =COUNTUNIQUE(A2:A20). Or combine UNIQUE with COUNTA.

Performance and Limitations

COUNTIF is fast even on large datasets, but there are limits. Google Sheets has a maximum of 10 million cells per spreadsheet, and COUNTIF will process the entire range you specify. If you use entire columns like A:A, it may slow down your sheet because it checks 1,000,000+ cells. It's better to limit the range to your actual data (e.g., A2:A1000). Also, COUNTIF does not support regular expressions (like REGEXMATCH); for regex-based counting, you'd need a helper column with REGEXMATCH and then COUNTIF on that column.

Another limitation: COUNTIF is case-insensitive. If you need case-sensitive counting, you can use SUMPRODUCT with EXACT: =SUMPRODUCT(--EXACT(A2:A20, "Apple")).

Finally, remember that COUNTIF counts cells that match the criterion, not cells that contain the criterion as part of a larger text, unless you use wildcards. For exact matches, the cell must equal the criterion (for text, it ignores case). For numbers, it must equal the numeric value.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

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

Spotted an error in this guide? Let us know.