Excel COUNTIF Formula Explained: 6 Examples You Can Copy
The COUNTIF formula counts cells that match a condition. How many people are in the Sales department? How many orders are over 1000? How many invoices are still unpaid? One short formula answers all of these, and it updates itself the moment your data changes.
This guide takes about 15 minutes. You need only Excel — COUNTIF has been in every version for decades, and the same formulas work in Google Sheets. All six examples are in copy boxes you can paste into your own sheet, and a practice file at the end lets you try them on real data.

What the COUNTIF function does
Think of COUNTIF as asking Excel a counting question. You point it at a range of cells and describe what to count — the word “Sales”, numbers over 1000, names starting with A. Excel scans the range, tallies every match, and returns the total as a single number.
That automatic recounting is the real power. Add a new row to your table and the count grows on its own, with no manual tallying and no missed cells. COUNTIF is the counting partner of the IF formula: IF decides what to show, COUNTIF tells you how many.
The COUNTIF syntax
=COUNTIF(range, criteria)
- range — the cells to search, such as B2:B11 or a whole column like B:B.
- criteria — what to count. It can be text in quotes (“Sales”), a comparison (“>1000”), a wildcard (“A*”), or a cell reference.
Only two arguments, which is why COUNTIF is so quick to learn. The detail that trips people up is the criteria: text and comparisons go inside double quotes, while a plain number or a cell reference does not. The six boxes below cover every criteria style you will normally need.
Copy these formulas
Each box below works with the team data in the worked example further down (names in column A, department in B, sales in C, status in D). Copy a box, paste it into your own sheet, and change the ranges to match your data.
Basic COUNTIF — count how many people are in the Sales department:
=COUNTIF(B2:B11,"Sales")
COUNTIF with a threshold — count sales figures over 1000:
=COUNTIF(C2:C11,">1000")
COUNTIF with a wildcard — count names that start with the letter A:
=COUNTIF(A2:A11,"A*")
COUNTIF not-equal — count rows whose status is not Paid:
=COUNTIF(D2:D11,"<>Paid")
COUNTIFS — count Sales department members with sales over 1000 (two conditions at once):
=COUNTIFS(B2:B11,"Sales",C2:C11,">1000")
COUNTIF with a cell-reference criteria — count sales above the target typed in cell F1:
=COUNTIF(C2:C11,">"&F1)
A worked example
Here is the small team table used in every example above — names in A, department in B, sales in C, and payment status in D:
| Name (A) | Department (B) | Sales (C) | Status (D) |
|---|---|---|---|
| Ali | Sales | 1200 | Paid |
| Sara | Support | 800 | Pending |
| Ahmed | Sales | 1500 | Paid |
| Fatima | Sales | 2000 | Paid |
| Bilal | Support | 600 | Pending |
| Ayesha | Sales | 1100 | Paid |
| Hassan | Support | 950 | Paid |
| Maryam | Sales | 700 | Pending |
| Usman | Support | 1300 | Paid |
| Zainab | Sales | 1800 | Paid |
Put the basic COUNTIF in a spare cell — =COUNTIF(B2:B11,”Sales”) — and Excel returns 6, because six of the ten people are in Sales. Reading the formula aloud: “Count the cells in B2 to B11 that say Sales.” The threshold box returns 6 as well: 1200, 1500, 2000, 1100, 1300 and 1800 are all over 1000.
The other boxes read the same way. The wildcard “A*” matches Ali, Ahmed and Ayesha, so it returns 3 — the star means “anything after this”. The not-equal box counts the three Pending rows, because “<>Paid” means “not equal to Paid”. COUNTIFS returns 5: six people are in Sales, but Maryam’s 700 does not pass the over-1000 test, so only five match both conditions. Finally, with 1500 typed in F1, the cell-reference box returns 2 (Fatima’s 2000 and Zainab’s 1800) — change F1 and the count changes with it.
COUNTIF or COUNTIFS — which to use
COUNTIF checks one condition in one range. The moment your question has the word “and” in it — Sales department AND over 1000, Paid AND this month — you need COUNTIFS, which takes pairs of range and criteria and counts only rows where every condition is true. All the ranges in COUNTIFS must be the same size, or Excel returns a #VALUE! error.
COUNTIFS works in every modern Excel version and in Google Sheets with the same syntax, so there is no compatibility reason to avoid it. A good habit: use COUNTIF for single-condition counts because it is shorter to read, and reach for COUNTIFS as soon as a second condition appears. When you need to add numbers up instead of counting them, the same idea exists as SUMIF.
Try it yourself: download the practice file
The practice file has the same team table from the worked example, six tasks matching the six copy boxes, and an answers sheet. Download it here: Excel COUNTIF practice file (with answers). Write each formula in the Practice sheet, then check your answers. If a count looks wrong, check the criteria first — a missing quote or a stray space is the usual culprit.
Common mistakes
- Forgetting the quotes around criteria. =COUNTIF(B2:B11,Sales) gives a #NAME? error — text criteria must be “Sales” in double quotes.
- Writing >1000 without quotes. Comparisons are text too: it must be “>1000”, not >1000.
- Extra spaces in the data. “Sales ” with a trailing space does not match “Sales”. If a count is one short, check for hidden spaces.
- Ranges of different sizes in COUNTIFS. B2:B11 with C2:C12 returns #VALUE! — every range must cover the same number of rows.
- Counting text that looks like numbers. Sales figures pasted as text are ignored by “>1000”. Convert the column to real numbers first.
Errors you might see
- 0 — nothing matched. Usually a spelling difference, a trailing space, or numbers stored as text. Check the criteria against the actual cell contents.
- #VALUE! — in COUNTIFS, the ranges are different sizes. Make every range the same height and try again.
- #NAME? — the criteria text is missing its quotes, or the function name is misspelled. Check the quotes first.
COUNTIF also pairs well with lookups. Use it to check whether a value exists before running a VLOOKUP or XLOOKUP — if the count is zero, you can show a friendly message instead of an error.
Frequently asked questions
What does the COUNTIF formula do in Excel?
It counts how many cells in a range match a condition you give it. For example, =COUNTIF(B2:B11,”Sales”) counts every cell in B2 to B11 that says Sales, and the result updates automatically when the data changes.
How do I count cells greater than a number with COUNTIF?
Put the comparison inside quotes: =COUNTIF(C2:C11,”>1000″) counts values over 1000. The same pattern works for >=, <, <= and <> — the whole comparison always goes in double quotes.
Can COUNTIF count with two conditions?
Not by itself — COUNTIF takes one condition. Use COUNTIFS instead: =COUNTIFS(B2:B11,”Sales”,C2:C11,”>1000″) counts rows where both conditions are true. You can add more range-and-criteria pairs for more conditions.
Why does my COUNTIF return 0 when matches exist?
Almost always a hidden mismatch: a trailing space in the data, a spelling difference, or numbers stored as text. Click a cell that should match and compare it character by character with your criteria.
Does COUNTIF work in Google Sheets?
Yes — COUNTIF and COUNTIFS work in Google Sheets with the same syntax, including wildcards and cell-reference criteria. Every formula in this guide can be pasted into a sheet there unchanged.
Quick recap
=COUNTIF(range, criteria) counts matches; =COUNTIFS adds more conditions. Quotes around text and comparisons, wildcards like “A*” for partial matches, “<>” for not-equal, and “>”&F1 to count against a target cell. Master these six patterns and most everyday counting questions answer themselves.
