Math
COUNTIF
Definition
COUNTIF returns how many cells in a range meet one criterion.
Syntax
=COUNTIF(range, criteria)
Arguments
| Argument | Meaning |
|---|---|
range |
The cells to test, such as B2:B5. |
criteria |
The test each cell must meet. A number can be typed as is; text must sit in double quotes. |
Worked example
A warehouse logs crate sizes. The sizes are in B2:B5.
| A: Crate | B: Size |
|---|---|
| Crate 1 | 4 |
| Crate 2 | 7 |
| Crate 3 | 4 |
| Crate 4 | 4 |
Formula: =COUNTIF(B2:B5,4)
Result: 3. Size 4 appears in B2, B4, and B5, so three cells match.
Practice
Cells A2:A5 hold 12, 8, 15, and 8. In B2, write a formula that counts how many cells equal 8.
- In B2, write a COUNTIF formula that counts how many cells in A2:A5 equal 8.
- B2 should show how many cells in A2:A5 equal 8.
Step 1 of 2
Enter =COUNTIF(A2:A5,8) in B2.
8 appears in A3 and A5, so the count is 2.
Formulas here use English function names, such as SUM, and a period as the decimal separator, in every language.
Loading the sheet…
B2 uses COUNTIF.
B2 now shows 2.
Related functions
COUNT tallies every numeric cell, and IF tests one cell; COUNTIF combines a range with one test.
Common mistake
Reversing the arguments, as in =COUNTIF(4,B2:B5): the range comes first, then the criterion.