COUNTIF Formula in Google Sheets: How to Use It

How-to basics · Updated November 23, 2026

The COUNTIF formula in Google Sheets counts cells that meet a single condition, and its syntax is =COUNTIF(range, criterion). For example, =COUNTIF(A2:A100, "Paid") returns the number of cells in A2:A100 that contain the word “Paid”. This article explains how it works, how to use it with numbers, text, and wildcards, and how to avoid common errors.

What COUNTIF Does and Why It Matters

COUNTIF is one of the most-used functions in Google Sheets because it turns raw data into quick answers: How many orders are over $100? How many students scored above 90? How many times does “Urgent” appear in a column? It saves you from manually scanning hundreds of rows. It is part of a family of counting functions that includes COUNT, COUNTA, COUNTBLANK, and COUNTIFS (the plural version for multiple conditions).

Unlike COUNT, which only counts numbers, COUNTIF can count text, numbers, dates, and even cells that are blank or non-blank, depending on the criterion you write. It is the go-to tool for basic conditional counting in Google Sheets.

COUNTIF Syntax and Arguments

The function takes exactly two arguments:

  • range – the cells to check. This can be a single column (A2:A100), a row (B1:Z1), or a rectangular block (A2:C100).
  • criterion – the condition that determines which cells to count. It can be a number, text, a cell reference, or a logical expression wrapped in quotes.

Examples of valid criteria:

  • "apple" – counts cells that exactly match the text apple (case-insensitive).
  • “<>“&B1 – counts cells that are not equal to the value in B1.
  • "*" – counts non-empty cells (but not truly blank ones).
  • "<100" – counts numbers less than 100.
  • "?at" – counts cells like "cat" or "bat" (single wildcard character).

Note that when you use a comparison operator like > or <>, you must enclose the entire criterion in double quotes. For cell references, you concatenate with an ampersand: "<"&B1.

How to Use COUNTIF with Text, Numbers, and Dates

Here are practical examples with a sample dataset. Assume column A contains a list of items and column B contains their prices.

  1. Counting exact text: With items in A2:A20, =COUNTIF(A2:A20, "Shirt") counts how many cells say "Shirt" exactly (ignoring case).
  2. Counting numbers greater than a value: With prices in B2:B20, =COUNTIF(B2:B20, ">50") counts prices above 50. This returns a number like 7.
  3. Counting with a cell reference: If cell D1 contains the number 100, =COUNTIF(B2:B20, ">"&D1) counts prices greater than 100.
  4. Counting dates: With dates in C2:C20, =COUNTIF(C2:C20, ">="&DATE(2024,1,1)) counts dates on or after January 1, 2024.
  5. Counting blank or non-blank cells: =COUNTIF(A2:A20, "") counts truly blank cells, while =COUNTIF(A2:A20, "<>") counts non-blank cells (including cells with empty text).

For a worked example: if B2:B20 contains the numbers 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, then =COUNTIF(B2:B20, ">50") returns 5 (60, 70, 80, 90, 100).

Using Wildcards in COUNTIF

Google Sheets supports three wildcards in COUNTIF:

  • Asterisk (*) – matches any sequence of characters. =COUNTIF(A2:A20, "Sh*") counts cells starting with "Sh" (Shirt, Shoes, etc.).
  • Question mark (?) – matches any single character. =COUNTIF(A2:A20, "B?g") counts "Bag" and "Big" but not "Bog"? Actually it matches any three-letter word starting with B and ending with g.
  • Tilde (~) – escapes the wildcard. To count cells that literally contain an asterisk, use =COUNTIF(A2:A20, "~*").

Wildcards are case-insensitive. To count cells that contain a specific substring anywhere, use "*text*". For example, =COUNTIF(A2:A20, "*red*") counts cells that contain "red" anywhere in the text.

COUNTIF vs. COUNTIFS: When to Use Which

COUNTIF handles a single condition. If you need to count cells that meet multiple conditions at once, use COUNTIFS. For example, to count orders in column A that are "Shirt" and have a price over $50 in column B, you would write:

=COUNTIFS(A2:A20, "Shirt", B2:B20, ">50")

COUNTIFS accepts multiple range/criterion pairs. It counts only rows where all conditions are true. In contrast, using two separate COUNTIF functions would count them independently and could double-count.

Another difference: COUNTIF with a range that includes multiple columns counts each cell individually, but COUNTIFS works on corresponding rows. For example, =COUNTIF(A2:C20, "Yes") counts every "Yes" in that block, while =COUNTIFS(A2:A20, "Yes", B2:B20, "Yes") counts rows where both A and B are "Yes".

Common Errors and How to Fix Them

Users often run into a few pitfalls:

  • #N/A error: This usually means the criterion is invalid. For example, using =COUNTIF(A2:A20, >50) without quotes causes an error. Always quote the comparison operator: ">50".
  • Case sensitivity: COUNTIF is not case-sensitive by default. If you need case-sensitive counting, you have to use a workaround like =SUMPRODUCT(--EXACT(A2:A20, "Apple")).
  • Counting blank cells: =COUNTIF(A2:A20, "") counts only truly empty cells. If a cell contains a formula that returns an empty string (""), it will not be counted as blank. Use =COUNTBLANK(A2:A20) to count both truly blank and empty-string cells.
  • Leading/trailing spaces: Text with extra spaces won't match exactly. Use =COUNTIF(A2:A20, "*Shirt*") to ignore surrounding spaces, or clean your data with TRIM.
  • Using COUNTIF on an entire column: =COUNTIF(A:A, "Yes") works, but it counts the header if it says "Yes". Better to specify a finite range.

Frequently Asked Questions

Can COUNTIF count cells that contain a specific word anywhere? Yes, use wildcards: =COUNTIF(A2:A20, "*word*"). This counts cells where "word" appears at the start, middle, or end.

How do I count cells that are not equal to a certain value? Use =COUNTIF(A2:A20, "<>"&B1) where B1 holds the value to avoid. Or directly: =COUNTIF(A2:A20, "<>Paid").

Can I use COUNTIF with colors? No, COUNTIF cannot check cell background or text color. You would need Google Apps Script or a workaround with helper columns that store the color information.

Why is my COUNTIF returning 0 when I see matching values? Check for extra spaces, non-printing characters, or that the criterion is not quoted correctly. For numbers, ensure they are stored as numbers, not text. Use =COUNTIF(A2:A20, "*"&B1&"*") to be more flexible.

Is COUNTIF case-sensitive? No, it ignores case. For case-sensitive counting, use =SUMPRODUCT(--EXACT(A2:A20, "Apple")).

Can I use COUNTIF across multiple sheets? Yes, reference another sheet like =COUNTIF(Sheet2!A2:A20, "Yes"). For multiple sheets, you would need to add multiple COUNTIF results or use a different approach.

Alternatives to COUNTIF

If you need more flexibility, consider these alternatives:

  • COUNTIFS – for multiple conditions.
  • SUMPRODUCT – for array-based counting with complex criteria, such as case-sensitive or OR logic.
  • FILTER – to extract matching rows and then use COUNTA on the result.
  • QUERY – to count with SQL-like syntax: =QUERY(A2:B20, "select count(A) where B > 50").
  • Pivot tables – for quick visual counts without formulas.

Each has its strengths. COUNTIF is the simplest for a single condition; SUMPRODUCT is more powerful but harder to read; QUERY is great for complex aggregations.

Conclusion

COUNTIF is a fundamental tool in Google Sheets for conditional counting. With the syntax =COUNTIF(range, criterion), you can count text, numbers, dates, and use wildcards for partial matches. Remember to quote comparison operators, use COUNTIFS for multiple conditions, and watch out for common errors like case sensitivity and blank cells. Once mastered, COUNTIF will save you time on everyday data tasks.

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.