COUNTIF
How many are unpaid, how many scored 80 or more? COUNTIF counts cells that meet a condition, COUNTIFS handles several. Syntax, examples and a practice sheet.
- Free, no sign-up
- No upload – files stay on your device
- Phone, tablet and computer
COUNTIF counts the cells that meet a condition: how many invoices are unpaid, how many students scored 80 or more, how many orders came from Chicago. COUNTIFS does the same with several conditions at once. The practice sheet above has 15 class sign-ups and four questions to answer with counting formulas.
COUNTIF syntax
=COUNTIF(range, criteria)
- range is the area in which you count, such as
D2:D16. - criteria says what counts: a text like
"pending", a number, a comparison like">=80"or a cell reference.
Example: =COUNTIF(D2:D16,"pending") returns 5, because five sign-ups in the payment column say “pending”.
Practice right here
Each question on the right of the sheet needs one formula. Type it into the green cell and click Check:
- How many haven’t paid yet? Count a text.
- How many scored at least 80? Count with a comparison.
- How many signed up for a spreadsheet course? Count with a wildcard.
- How many online attendees have paid? Count with two conditions.
Typical slips get a friendly hint, for example when you count scores above 80 instead of 80 and above.
Criteria examples
| You want to count | Formula |
|---|---|
| Cells with exactly this text | =COUNTIF(D2:D16,"paid") |
| Values of 80 or more | =COUNTIF(E2:E16,">=80") |
| Everything except one value | =COUNTIF(C2:C16,"<>Online") |
| Text that starts with a word | =COUNTIF(B2:B16,"Spreadsheet*") |
| Text that contains a word | =COUNTIF(B2:B16,"*Basics*") |
| The value in another cell | =COUNTIF(C2:C16,G1) |
| Non-empty cells | =COUNTIF(A2:A16,"<>") |
The asterisk * stands for any number of characters, the question mark ? for exactly one. Upper and lower case don’t matter.
COUNTIFS for several conditions
COUNTIFS only counts rows in which all conditions are met. You write pairs of range and criteria:
=COUNTIFS(C2:C16,"Online",D2:D16,"paid") returns 4: seven people take the class online, but only four of them have paid.
A range from-to works with the same column twice: =COUNTIFS(E2:E16,">=70",E2:E16,"<80") counts the scores from 70 to 79.
Common mistakes
- Result 0: text without quotation marks, a typo, or a space at the end of the cell values.
- One too few:
">80"leaves out 80 itself. “At least” means">=80". - Wildcard missing:
"Spreadsheet"only finds cells that contain exactly that word. - Ranges of different sizes in COUNTIFS: every range must cover the same rows.
- Wrong function: COUNT counts numbers only and COUNTA counts every non-empty cell; neither takes a condition.
=COUNTIF($B$2:$B$16,B2)>1 is TRUE for every value that occurs more than once. To clean up a list for good, see removing duplicates.Frequently asked questions
What’s the difference between COUNTIF and COUNTIFS?
COUNTIF takes one condition, COUNTIFS up to 127 pairs of range and criteria. With a single pair, both return the same result.
Can COUNTIF count with an OR condition?
Add two formulas: =COUNTIF(C2:C16,"Chicago")+COUNTIF(C2:C16,"Denver").
How do I add up values instead of counting them?
Use SUMIF. It takes the same criteria and adds a third argument for the values to add.
Does COUNTIF work without Excel?
Yes. Practice it above, or count in your own lists with the free Spreadsheet Editor in your browser.
Microsoft Excel is a trademark of Microsoft Corporation. The Spreadsheet Editor is not affiliated with Microsoft.