Spreadsheet Practice

COUNTIF function

COUNTIF counts the cells in a range that meet one condition: tickets marked "Open", scores of 70 or more, product names containing "lamp". The condition can be an exact value, a comparison in quotes such as ">1000", a wildcard pattern, or a cell reference.

Available in
Every current version
Category
Conditional sum and count functions
Returns
The number of cells that meet the condition.
Google Sheets
Also available in Google Sheets.

Syntax

=COUNTIF(range, criteria)

ArgumentRequired?What it is
rangeRequiredThe cells to check.
criteriaRequiredThe condition: a value like "Open", a comparison like ">=3", a pattern like "*login*", or a cell.

Examples

Each result below is calculated from the sample sheet by our formula engine, the same one that grades the practice.

CellFormulaResultWhat it shows
G2=COUNTIF(B2:B8,"Open")4Matching ignores case, so "open" counts too
G3=COUNTIF(C2:C8,">=3")4A comparison goes inside the quotes
G4=COUNTIF(D2:D8,"*login*")3Wildcards: * matches any characters around the word

Try it live

This is the sample sheet. Change any number or text, or edit a formula, and the results update.

Show the sample data as a table
TicketStatusDays openSubjectCheckResult
T-101Open4Login issueOpen tickets4
T-102Closed1Billing questionOpen 3+ days4
T-103Open7Login is slowAbout login3
T-104Pending2Refund request
T-105Open1New user setup
T-106Closed5Password reset
T-107open3Login loop

Practice COUNTIF

From lesson 7, COUNTIF & SUMIF. Graded instantly, then re-checked on changed data.

Count by region

In G2, count how many orders came from the East region.

Common mistakes

What you seeWhy, and how to fix it
The count is 0 for a comparisonThe operator must be inside quotes: ">=3", not >=3. To compare with a cell, join them: ">="&E2.
Text with extra spaces doesn't match"Open " with a trailing space isn't "Open". Clean the data with TRIM.
Counts are off by a fewCOUNTIF ignores case, so it can't tell "ABC" from "abc". Use SUMPRODUCT with EXACT if case matters.

Tips

  • Use "<>" to count non-empty cells and "<>Closed" to count everything except one value.
  • For two or more conditions, switch to COUNTIFS rather than nesting COUNTIFs.

Questions

How do I count cells that contain specific text?

Use wildcards: =COUNTIF(D2:D8,"*login*") counts any cell containing "login".

How do I count cells greater than a value in another cell?

Join the operator and the cell: =COUNTIF(C2:C8,">"&F2).

Is COUNTIF case-sensitive?

No. "open", "Open" and "OPEN" all match.

Lessons that use COUNTIF

Last reviewed October 2026. Every example result on this page is calculated live by the Spreadsheet Practice formula engine.