COUNTIF Function
COUNTIF counts cells that match a condition. Give it a range and a criterion (like '>100' or 'East') and it tells you how many cells pass the test.
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| range | The range of cells to count. Each cell is evaluated against the criteria. | Required |
| criteria | The condition that determines which cells to count. Can be a number, text, comparison, or wildcard pattern. | Required |
Basic Example
Count how many students scored 80 or above
=COUNTIF(A2:A30, ">=80")The formula checks each cell in A2:A30 and counts how many contain a value of 80 or higher.
Advanced Examples
Example 1: Count occurrences of specific text
Survey analysisCount how many responses say 'Yes'
=COUNTIF(B2:B100, "Yes")Example 2: Count with wildcard for partial text
Data analysisCount cells containing 'error' anywhere in the text
=COUNTIF(A2:A50, "*error*")Example 3: Count non-blank cells
Data qualityCount how many cells in a range are not empty
=COUNTIF(A2:A100, "<>")How COUNTIF Works
COUNTIF scans each cell in the range and checks it against your criteria. For exact text matches, it does a case-insensitive comparison. For numeric criteria like '>100', it evaluates the comparison operator. For wildcards, * matches any sequence of characters and ? matches exactly one character. Each cell that passes the test increments the count by 1. The result is a single number: the total count of matching cells.
Important Notes & Limitations
COUNTIF handles only one condition. For multiple conditions, use COUNTIFS.
Text criteria are case-insensitive — 'yes' and 'YES' both match.
COUNTIF cannot count cells by color, font, or other visual formatting.
For counting unique values, COUNTIF alone isn't sufficient — combine with UNIQUE or advanced formulas.
Common Errors & Fixes
0 result (criteria not matching)The criteria text/number doesn't exist in the range, or there's a formatting mismatchFix: Double-check that the values in the range actually match your criteria. Watch for trailing spaces.
Unexpected count (text vs number)Numbers stored as text won't match numeric criteria like '>100'Fix: Convert text numbers to actual numbers, or use text criteria: =COUNTIF(A2:A50, ">100") may not work on text-formatted numbers.
Wrong count with wildcardsWildcard criteria treating numbers as textFix: Wildcards only work on text content. Numeric cells won't match wildcard patterns.
Download Practice File
COUNTIF
countifPractice COUNTIF with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the COUNTIF function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps