The COUNTIF function
Counts the cells in a range that meet one condition. Text conditions ignore upper and lower case.
How to use COUNTIF
COUNTIF answers the question "how many?" for one condition. Think of ticking names off a list: how many say North, how many sales are over 300, how many cells are still empty.
You give it the range to look through and the condition: =COUNTIF(A2:A10,"North"). Text matching ignores upper and lower case, and the condition has to match the whole cell unless you use wildcards. "*north*" finds north anywhere in the cell and "N*" finds everything that starts with N. Numbers and dates use a comparison in quotes, such as ">=300". To compare with a cell, join the two with &, like "<>"&D1.
Two shortcuts are worth knowing: "<>" counts the cells that are not empty, and "" counts the empty ones.
There is no sum range here, because the range you check is also the range you count. COUNTIF holds one condition. For several conditions, or for values between two limits, use COUNTIFS. To add up amounts instead of counting rows, use SUMIF.
Syntax
COUNTIF(range, criteria)- range
- The cells to count.
- criteria
- The condition, such as "North", ">=300", "*shoe*" or a cell.
Examples
=COUNTIF(1A2:A6,2"North")| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Region | Product | Sales | 3 | |
| 2 | North | Shoes | 500 | ||
| 3 | South | Shoes | 300 | ||
| 4 | North | Bags | 250 | ||
| 5 | North | Shoes | 420 | ||
| 6 | South | Bags | 180 |
In plain words: Count the cells 1in A2:A6 that say 2North.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Region | Product | Sales | 3 | |
| 2 | North | Shoes | 500 | ||
| 3 | South | Shoes | 300 | ||
| 4 | North | Bags | 250 | ||
| 5 | North | Shoes | 420 | ||
| 6 | South | Bags | 180 |
Common COUNTIF mistakes
COUNTIF returns 0 for text that is clearly in the cells
A text condition has to match the whole cell. To find a word anywhere inside the text, put asterisks around it:
=COUNTIF(A2:A6,"*north*"). Extra spaces at the start or end of a cell also break an exact match.A condition like ">E1" counts nothing
Inside quotes, E1 is just the two letters E1. Join the operator and the cell with &:
=COUNTIF(C2:C6,">"&E1).COUNTIF shows an error when I give it two conditions
COUNTIF takes one condition, so a second pair of range and condition is too many arguments. Use COUNTIFS and repeat the range:
=COUNTIFS(C2:C6,">=200",C2:C6,"<=400").Counting by date gives the wrong number
A date typed inside quotes depends on the date settings of the file, and dates stored as text are not counted as dates. Build the date with DATE:
=COUNTIF(A2:A100,">"&DATE(2024,1,1)).
Practice COUNTIF
Read the guide
- Free Excel course online: learn Excel from your first formula to job-ready
- Pivot tables explained, and the formulas that do the same job
- Conditional formatting in Excel: highlight cells and rows with rules and formulas
- How to create a drop-down list in Excel, and make it update itself
- Excel practice data: free datasets with tasks and answers
- Excel calendar 2026: build your own with week numbers and holidays
- Excel inventory data: free practice file with tasks and answers
- Excel customer data: free practice file with tasks and answers
- Excel data cleaning practice: a messy file with tasks and answers
- Excel finance data: free practice file with tasks and answers
Questions
How do I count cells that contain a word?
Use wildcards: =COUNTIF(A2:A6,"*north*") counts cells with "north" anywhere in them.
How do I use COUNTIF with multiple criteria?
COUNTIF takes one condition. Use COUNTIFS when every condition must be true: =COUNTIFS(A2:A6,"North",B2:B6,"Shoes"). When either condition may be true, add two COUNTIF formulas: =COUNTIF(A2:A6,"North")+COUNTIF(A2:A6,"South").
How do I count cells that are not empty?
Use <> as the condition: =COUNTIF(A2:A6,"<>") counts the cells that have something in them, and =COUNTIF(A2:A6,"") counts the empty ones.
How do I count cells that do not equal a value?
Put <> in front of the value: =COUNTIF(A2:A6,"<>North"). If the value is in a cell, write "<>"&D1.