COUNTIF Function
The Excel COUNTIF function counts cells that meet one condition. It works with text, numbers, dates, comparison operators, blanks, and wildcard patterns.
| Excel COUNTIF Function | |||||||
| Count records that meet one criterion; edit the source data and criteria to see each count update. | |||||||
| Source data, editable | COUNTIF examples | ||||||
| Region | Status | Amount | Example | Criterion | Formula syntax | Result | |
| North | Open | 1,200.0 | Records in selected region | North | =COUNTIF(A12:A21,F12) | 4 | |
| South | Closed | 850.0 | Records with selected status | Open | =COUNTIF(B12:B21,F13) | 4 | |
| North | Open | 1,450.0 | Amounts above threshold | >1000 | =COUNTIF(C12:C21,F14) | 5 | |
| West | Pending | 0.0 | Nonblank status cells | <> | =COUNTIF(B12:B21,F15) | 9 | |
| East | Closed | 1,100.0 | |||||
| North | 760.0 | How to read the examples | |||||
| South | Open | 1,325.0 | The criteria range decides which rows qualify. | ||||
| West | Closed | -100.0 | The editable criterion can be text, a number, or an operator expression. | ||||
| North | Pending | 980.0 | The result updates when source values or the criterion changes. | ||||
| East | Open | 1,500.0 | |||||
| Reliability checks | |||||||
| Region count agrees with a direct equality test | OK | ||||||
| Blank status is excluded from the nonblank count | OK | ||||||
Overview
The Excel COUNTIF function counts cells that satisfy one rule. Use it for questions such as how many orders are open, how many amounts exceed a threshold, or how many cells are not blank.
Quick reference
Syntax: =COUNTIF(range, criteria)
Returns: The number of cells in the range that satisfy the criterion. (number)
Arguments:
range(required) — The cells Excel evaluates and counts.criteria(required) — The text, number, expression, cell reference, or wildcard pattern that determines which cells count.
Both arguments are required. The criterion may be a number, text value, expression, cell reference, or wildcard pattern, with operators such as > written inside quoted criteria text.
Common uses
- Count records in one category, region, owner, or workflow status.
- Count amounts above or below a visible threshold.
- Measure blanks or completed fields in a data-quality check.
- Count text that begins with, ends with, or contains a pattern.
Calculations
COUNTIF tests every cell in range against the same criterion and returns the number of matches. It applies one condition only; use COUNTIFS when the same record must pass two or more conditions.
Plain text or a direct numeric value can be supplied as the criterion. Comparison operators must be text, so a fixed threshold is written as ">1000". When the threshold comes from another cell, join the operator to the reference, as in ">"&F14. Do not put the cell reference itself inside quotation marks.
Text matching is not case-sensitive. The wildcard * matches any sequence of text characters, ? matches one character, and ~ escapes a literal wildcard. COUNTIF expects a worksheet range for its first argument; an array calculated by another function is not a direct substitute.
Function behavior
Situation | Behavior |
|---|---|
No matches | Returns |
Text case | Matching is not case-sensitive. |
Blank criterion | |
Comparison operators | Operators such as |
Wildcards | |
Dates | Dates can be compared as Excel serial numbers; a cell reference or |
Errors | Error cells are counted only if the criterion targets that error; an invalid formula or unsupported reference can return an error. |
Calculated arrays | |
Common errors
Leaving a comparison operator unquoted
What happens:
Excel cannot interpret a criterion such as >1000 when it is entered directly as formula syntax.
Better approach:
Use ">1000", or concatenate a reference with ">"&F14.
Putting a cell reference in quotation marks
What happens:"F14" is treated as literal text instead of the value stored in cell F14.
Better approach:
Use F14 for an equality test or concatenate it to an operator.
Trying to apply several conditions with one COUNTIF
What happens:
The formula can test only one range-condition pair.
Better approach:
Use COUNTIFS for AND logic across multiple criteria ranges.
Including a header in the range
What happens:
The header can become an unintended match, especially with text or wildcard criteria.
Better approach:
Start the range at the first data row and keep its boundaries explicit.
Example
Example 1 — Count a Text Value
=COUNTIF(A12:A21,F12)
With North in F12, this formula counts the matching region cells. The example workbook returns 4.
Example 2 — Count a Status
=COUNTIF(B12:B21,F13)
This applies the value in F13 to the Status range. With Open selected, the result is 4.
Example 3 — Count Values Above a Threshold
=COUNTIF(C12:C21,F14)
In the workbook, F14 contains the criterion >1000. Five amounts satisfy that comparison.
Example workbook
The workbook contains a COUNTIF Example sheet with ten editable Region, Status, and Amount records. Four live formulas demonstrate text, comparison, and nonblank criteria, while two checks reconcile the visible region count and blank handling. A Notes sheet summarizes syntax and criteria rules.
Key takeaway
Use COUNTIF for one visible condition, and write operator-based criteria as text or as an operator concatenated to a cell reference.