Excel COUNTIF Function: How to Count Cells with Criteria

Learn how to use the Excel COUNTIF function to count cells that match a condition. See formula examples for text, numbers, cell references, and wildcards.

Syntax

=COUNTIF(range, criteria)

Arguments

Count cells that match specific text

Use COUNTIF to count cells containing an exact word or text string. Text comparisons in Excel are case-insensitive, so "Apples" and "apples" match the same cells. Always enclose text criteria in double quotes.

ItemQuantity
Apples14
Oranges8
Apples22
Bananas15
Apples5
Apples orders

Formula: =COUNTIF(A2:A6, "Apples") → 3

Count numbers with greater than or less than

To count numbers above or below a threshold, combine a comparison operator with your number inside quotation marks. For example, use ">=50" to include values equal to 50, or "<20" to find smaller values.

CustomerScore
Tara45
Liam78
Noah92
Emma34
Zoe60
Passing (>=50)

Formula: =COUNTIF(B2:B6, ">=50") → 3

Use a cell reference for dynamic criteria

You can supply criteria from another cell instead of hardcoding a value. Do not put quotation marks around the cell reference. If the criterion cell changes, your count updates automatically.

TaskPriority
Backup dataHigh
Update stylesLow
Fix login bugHigh
Write testsMedium
Deploy buildHigh
TargetHigh
High tasks

Formula: =COUNTIF(B2:B6, B7) → 3

Count partial matches with wildcards

Use wildcards when you only know part of the text. An asterisk * matches any number of characters, and a question mark ? matches any single character. To count cells that contain a keyword anywhere inside, place an asterisk on both sides, such as "*Report*".

ProjectOwner
Finance ReportSara
User ResearchKen
Weekly ReportAlex
Logo DesignMina
Annual ReportSara
Report count

Formula: =COUNTIF(A2:A6, "*Report*") → 3

Common mistake: missing quotes on comparisons

A frequent mistake is omitting quotes around comparison operators, writing =COUNTIF(B2:B6, >=50) instead of =COUNTIF(B2:B6, ">=50"). Excel flags unquoted operators as syntax errors. If you need to combine an operator with a cell reference such as C1, join them using an ampersand: ">="&C1.

Related guides

SUMIFSUMIFAVERAGE