COUNTIF
Count the cells in a range that meet a single condition with Excel's COUNTIF function.
Spreadsheet editor
Spreadsheet editor
Syntax
=COUNTIF(range, criteria)
Returns: Number Arguments
| Argument | Required | Description |
|---|---|---|
| range | Yes | The range of cells you want to count. |
| criteria | Yes | The condition that decides which cells get counted. Can be a number, text, a cell reference, or an expression like ">=100" or "North*". |
About
The criterion can be a number, text, or a comparison like ">=80" or "<>0". You can also use wildcards in text criteria: ? matches any single character and * matches any run of characters. COUNTIF is case-insensitive, so "north" and "NORTH" count the same.
COUNTIF only handles one condition. When you need to count against two or more conditions at once, use COUNTIFS. To add up values that meet a condition instead of counting them, reach for SUMIF, and for a conditional average try AVERAGEIF.
Exercises using COUNTIF
Basic COUNTIF
BeginnerUse COUNTIF to count cells that match one condition in a list.
Open exerciseCount employees by department with COUNTIF
BeginnerUse COUNTIF to count how many employees belong to each department in a company roster.
Open exerciseCOUNTIF for text matching
BeginnerUse COUNTIF to count how many support tickets have each status in a helpdesk log.
Open exerciseBuild a basic cohort retention table
IntermediateBuild a customer cohort retention grid by counting each signup cohort and calculating what share stayed active in later months.
Open exerciseCount cells containing text
IntermediateCount how many notes fields contain the word "urgent".
Open exerciseCross-reference two lists with FILTER
IntermediateUse spill formulas to reconcile a product catalog against order history and surface missing records in both directions.
Open exerciseRemove duplicate customer records
IntermediateUse COUNTIF with an expanding range to mark which customer records to keep and which repeats to remove.
Open exerciseExamples
Count against a target in a cell
Spreadsheet editor
Count text with a wildcard
Spreadsheet editor
Flag duplicate emails
Spreadsheet editor
Watch out for
Operators need to be inside quotes
Writing the criterion as =COUNTIF(B2:B50, >=80) returns an error because Excel does not expect a bare operator there.
→ Wrap the whole condition in quotes: =COUNTIF(B2:B50, ">=80").
Comparing against a cell value
Putting the cell reference inside quotes, like ">=E1", makes Excel look for the literal text "E1" instead of the number in E1.
→ Join the operator and the reference with &: =COUNTIF(B2:B50, ">="&E1).
Expecting case-sensitive counts
COUNTIF treats "Apple" and "apple" as the same value, so you cannot count one casing separately.
→ For case-sensitive counts, combine SUMPRODUCT with EXACT instead.
Trying to use two conditions
COUNTIF only accepts one criterion, so you cannot count cells that match two rules at once.
→ Switch to COUNTIFS, which lets you stack several range and criteria pairs.