Counting · About 5 minutes
Count what matches with COUNTIF
COUNTIF counts the cells in a range that match a rule. The rule is called a condition.
=COUNTIF( reads as "count the cells from B2 to B7 that say Sales". The range comes first, then a comma, then the condition.
Put the condition in quotes. For numbers you can add a comparison inside the quotes: ">60000" means more than 60,000, and "<>Sales" means anything except Sales.
How COUNTIF counts
Exercise 1 of 3 · Worked example
In B9, count the staff in Sales. Type =COUNTIF( B2:B7, "Sales") and press Enter.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Department | Salary ($) |
| 2 | Priya Nair | Sales | 52,000 |
| 3 | Arjun Mehta | Accounts | 64,000 |
| 4 | Fatima Shaikh | Sales | 47,500 |
| 5 | Vikram Rao | Sales | 66,000 |
| 6 | Neha Gupta | Sales | 69,000 |
| 7 | Suresh Iyer | HR | 78,000 |
| 8 | |||
| 9 | In Sales | (answer cell) |
Questions people ask
How do I COUNTIF greater than a number?
Put the sign and number in quotes: =COUNTIF(. To use a number from a cell, join it with &: =COUNTIF(.
How do I count cells that are not blank with COUNTIF?
Use "<>" as the condition: =COUNTIF(.
Is COUNTIF case-sensitive?
No. "sales", "Sales" and "SALES" all match the same cells.
How do I use COUNTIF with more than one condition?
Use COUNTIFS. It takes a range and a condition for each test.
Why is my COUNTIF returning 0?
Often the sign is outside the quotes, the cells have stray spaces, or the numbers are stored as text. Check one matching cell by eye first.
How do I find duplicates with COUNTIF?
Fill down =COUNTIF( beside the list. It shows TRUE for every value that appears more than once. How to find duplicates in Excel with COUNTIF