Conditional sums and counts
COUNTIF function playground
Counts the cells that meet one condition.
The playground runs in your browser. Nothing you type is sent anywhere.
How COUNTIF works
COUNTIF checks every cell in the range and counts the ones that meet the condition.
The criteria can be text, a number, a comparison in quotes, or a pattern with wildcards: * stands for any number of characters, ? for exactly one. "<>" & "" counts cells that are not empty.
Syntax
=COUNTIF(range, criteria)| Argument | What it means |
|---|---|
rangerequired | The cells to check. |
criteriarequired | The condition, such as "East", ">1500" or a cell reference. |
Examples
| Formula | What it does | Result |
|---|---|---|
=COUNTIF(B2:B11,I1) | How many sales were in the region typed in I1. | 4 |
=COUNTIF(F2:F11,">1500") | Sales above 1,500. | 4 |
=COUNTIF(D2:D11,"<>Laptop") | Sales that were not laptops. | 6 |
=COUNTIF(C2:C11,"A*") | Sales by reps whose name starts with A. | 3 |
Common mistakes
Extra spaces"East " with a trailing space doesn't match "East". Clean the data with TRIM.
Numbers as textCOUNTIF(range,"5") matches both 5 and the text "5"; other functions may not.
Related functions
Learn more
Download the example workbook (.xlsx)
The workbook has the same sample data and formulas, plus a practice sheet.