Comparison Operators in Excel — With Examples (=, <>, >, <, >=, <=)
Learn Excel comparison operators: equal, not equal, greater than, less than, and between two numbers, in IF, COUNTIF and SUMIF.
Read Guide →You have a list of ten orders and you need one number: how many came from the East, how many sales were over $1,000, how many rows are still unpaid. That is what COUNTIF does — it counts the cells in a range that pass one test you give it. The formula has two parts, =COUNTIF(range, criteria), and the only thing that trips people up is the quoting: text and comparisons go in double quotes, plain numbers and cell references do not. This guide gives you that rule first, then runs every example on one ten-row sales table, so you can check each answer yourself — text, numbers, dates, wildcards, blanks, a cell reference, and COUNTIFS for two conditions.
Quick takeaway: two parts — the range and the test.
=COUNTIF(range, criteria) — count the cells that pass one test."East", ">1000". Plain numbers and cell references do not: 1200, G2."East" matches east and EAST.COUNTIFS.
=COUNTIF(range, criteria)
| Part | What it does |
|---|---|
range | The group of cells Excel looks through — a column, a row, a block, or a named range |
criteria | The test a cell must pass to be counted — a number, text, a comparison, a cell reference, or a wildcard pattern |
Both parts are required, separated by a comma. The result is always a single number. And one rule covers most of the quoting confusion: text and anything with a comparison symbol goes inside double quotes, while plain numbers and cell references do not need them.
Every formula below uses this ten-row sales list. Type it into a blank sheet starting at A1 if you want to follow along and check each answer.
| Row | A: Rep | B: Region | C: Sales | D: Order Date | E: Status | F: Notes |
|---|---|---|---|---|---|---|
| 2 | Alex | East | 1200 | 9/3/2026 | Paid | Rush |
| 3 | Priya | West | 850 | 9/15/2026 | Pending | |
| 4 | Jordan | east | 2400 | 10/2/2026 | Paid | Gift wrap |
| 5 | Sam | North | 450 | 10/9/2026 | Paid | Call first |
| 6 | Alex | West | 1750 | 10/20/2026 | Pending | |
| 7 | Taylor | East | 600 | 10/22/2026 | Paid | Rush |
| 8 | Priya | East | 900 | 11/4/2026 | Pending | |
| 9 | Jordan | South | 1100 | 11/12/2026 | Paid | Delivery |
| 10 | Sam | West | 300 | 11/20/2026 | Pending | |
| 11 | Alex | North | 1500 | 12/1/2026 | Paid | Rush |
Row 1 holds the headings. Note two traps built into the table on purpose: row 4 has “east” in lowercase, and four Notes cells are empty — both are used in the examples below.
The most common use. The text goes in double quotes, and COUNTIF ignores case.
| Goal | Formula | Result |
|---|---|---|
| Orders from the East | =COUNTIF(B2:B11, "East") | 4 |
| Orders from the West | =COUNTIF(B2:B11, "West") | 3 |
| Orders handled by Alex | =COUNTIF(A2:A11, "Alex") | 3 |
| Orders that are Paid | =COUNTIF(E2:E11, "Paid") | 6 |
Why is East 4 and not 3? Jordan’s region in row 4 was typed as lowercase “east”, and COUNTIF ignores letter case. “East”, “east” and “EAST” all count as the same value. If your count looks one too high, check for a lowercase twin before anything else.
Numbers work the same way, but a comparison needs quotes around the operator and the number together.
| Goal | Formula | Result |
|---|---|---|
| Sales over $1,000 | =COUNTIF(C2:C11, ">1000") | 5 |
| Sales of $1,000 or more | =COUNTIF(C2:C11, ">=1000") | 5 |
| Sales under $500 | =COUNTIF(C2:C11, "<500") | 2 |
| Sales exactly $1,200 | =COUNTIF(C2:C11, 1200) | 1 |
| Sales not equal to $1,200 | =COUNTIF(C2:C11, "<>1200") | 9 |
Two things to notice. First, ">1000" and ">=1000" give the same answer here — 5 — because no sale is exactly $1,000. A sale of exactly $1,000 would be counted by ">=1000" and missed by ">1000". Second, a plain number needs no quotes: =COUNTIF(C2:C11, 1200) works, and so does =COUNTIF(C2:C11, "1200"). The quotes only become compulsory when an operator is involved — >1000 without quotes is not a valid formula.
Dates are criteria in quotes, just like text. Excel compares the date in the cell with the date in the quotes.
| Goal | Formula | Result |
|---|---|---|
| Orders after 1 Oct 2026 | =COUNTIF(D2:D11, ">10/1/2026") | 8 |
| Orders before 1 Oct 2026 | =COUNTIF(D2:D11, "<10/1/2026") | 2 |
The two answers add up to 10, the whole table — a good check that nothing was missed. One warning: the date in the quotes must be one Excel recognises as a date. If your dates are written day-first (3/9/2026 for 3 September), write the criteria the same way your Excel expects, or put the cutoff date in a cell and point at it instead — the cell-reference section below shows how.
When you want cells that contain a word, not just equal it, use wildcards. The asterisk (*) stands for any number of characters, including none. The question mark (?) stands for exactly one character.
| Goal | Formula | Result |
|---|---|---|
| Names starting with A | =COUNTIF(A2:A11, "A*") | 3 |
| Regions ending in “ast” | =COUNTIF(B2:B11, "*ast") | 4 |
| Names exactly 5 letters long | =COUNTIF(A2:A11, "?????") | 2 |
| Notes containing “Rush” | =COUNTIF(F2:F11, "*Rush*") | 3 |
“Names starting with A” gives 3 — the three Alex rows. “Regions ending in ast” gives 4 — the East rows, including the lowercase “east”. “Names exactly 5 letters long” gives 2 — the two Priya rows; Alex (4 letters), Taylor and Jordan (6 letters) and Sam (3 letters) do not match, because each ? is exactly one character. And “Rush” with an asterisk on both sides counts any cell containing the word Rush anywhere — 3 rows. This is the answer to “count if a cell contains specific text”: wrap the word in asterisks.
Blank cells have their own criteria. An empty pair of quotes counts the blanks; "<>" counts everything that is not blank.
| Goal | Formula | Result |
|---|---|---|
| Empty Notes cells | =COUNTIF(F2:F11, "") | 4 |
| Notes cells that are not empty | =COUNTIF(F2:F11, "<>") | 6 |
| Notes cells containing any text | =COUNTIF(F2:F11, "*") | 6 |
The two answers add up to 10 — another good check. "<>" and "*" give the same answer here, 6, because every non-empty Notes cell holds text. They differ when a cell holds a number: "*" counts only text, "<>" counts numbers too. The full guide to counting text cells is the count cells with text article, which runs the same idea on its own ten-row table.
Hard-coding “East” in the formula is fine once. When the value changes, put it in a cell and point at it — no quotes around the cell reference.
Say cell H2 holds the word East:
=COUNTIF(B2:B11, H2)
That gives 4, the same as "East". For a comparison against a cell, join the operator to the cell with &: say H3 holds 1000:
=COUNTIF(C2:C11, ">"&H3)
That gives 5, the sales over $1,000. Change H3 to 1500 and the count updates without touching the formula. The quotes stay only around the operator — the cell reference itself is never quoted.
COUNTIF applies only one condition. When two things must be true at once, use COUNTIFS — same idea, but every condition gets its own range and criteria, in pairs.
| Goal | Formula | Result |
|---|---|---|
| East orders that are Paid | =COUNTIFS(B2:B11, "East", E2:E11, "Paid") | 3 |
| West orders that are Pending | =COUNTIFS(B2:B11, "West", E2:E11, "Pending") | 3 |
| Sales over $1,000 that are Paid | =COUNTIFS(C2:C11, ">1000", E2:E11, "Paid") | 4 |
East and Paid gives 3: of the four East rows, three are Paid and one (Priya, row 8) is Pending. And if you want OR instead of AND — East or West — COUNTIFS cannot do it. Add two COUNTIFs together: =COUNTIF(B2:B11, "East") + COUNTIF(B2:B11, "West") gives 7.
Four functions that all count, and the difference is what they count.
| Function | Counts | Example on this table |
|---|---|---|
| COUNT | Numbers only | =COUNT(C2:C11) → 10 |
| COUNTA | Every non-empty cell | =COUNTA(F2:F11) → 6 |
| COUNTIF | Cells passing one condition | =COUNTIF(B2:B11, "East") → 4 |
| COUNTIFS | Cells passing two or more conditions | =COUNTIFS(B2:B11, "East", E2:E11, "Paid") → 3 |
| COUNTBLANK | Empty cells only | =COUNTBLANK(F2:F11) → 4 |
If your count is too high, you probably used COUNTA where you meant COUNTIF. If it is too low, you probably used COUNT where the cells hold text — COUNT ignores text entirely.
The most common failure, and it is almost never the function. Work through these in order.
| Check | What happens | Fix |
|---|---|---|
| A trailing space | The cell holds “East ” with a space, and COUNTIF does not trim spaces — "East" does not match "East " | Remove the space, or use =COUNTIF(B2:B11, "East*") |
| Numbers stored as text | The cell shows 1200 but holds text, so =COUNTIF(C2:C11, 1200) finds nothing | Convert the column to numbers first (Paste Special → Multiply by 1) |
| The formula sits inside its own range | Putting the formula in B12 while counting B2:B12 creates a circular reference | Put the formula outside the range it counts |
| An array instead of a range | COUNTIF requires an actual range — it will not accept an array | Point it at real cells, not an array expression |
| Mistake | What happens | Fix |
|---|---|---|
You wrote >1000 without quotes | Excel will not accept the formula | Put the operator and number in quotes: ">1000" |
| You quoted a cell reference | =COUNTIF(B2:B11, "H2") counts cells holding the text “H2” | Drop the quotes: =COUNTIF(B2:B11, H2) |
| You used COUNTIF for two conditions | It counts only the first condition, or errors | Use COUNTIFS, with a range and criteria for each condition |
| You expected case to matter | “East” and “east” counted together, and your count looks one too high | That is correct behaviour — check for a lowercase twin, or use an exact-match helper |
| You counted the heading row | The heading “Region” got counted as a value | Start the range at row 2, not row 1 |
What is the COUNTIF formula in Excel? =COUNTIF(range, criteria). For example, =COUNTIF(B2:B11, "East") counts how many cells in B2:B11 hold East. The result is a single number.
How do I count cells with specific text in Excel? Use COUNTIF with the text in double quotes: =COUNTIF(A2:A11, "Alex"). To count cells that contain a word anywhere, wrap it in asterisks: =COUNTIF(F2:F11, "*Rush*").
How do I count if a cell is not blank in Excel? =COUNTIF(F2:F11, "<>") counts the non-empty cells. =COUNTIF(F2:F11, "") counts the empty ones.
Is COUNTIF case-sensitive? No. “East”, “east” and “EAST” all count as the same value. If your count looks one too high, a lowercase twin is the usual cause.
What is the difference between COUNTIF and COUNTIFS? COUNTIF applies one condition to one range. COUNTIFS applies two or more conditions, each with its own range and criteria — every condition must be true. For OR logic (East or West), add two COUNTIFs together.
Why does my COUNTIF return 0? Usually a trailing space in the data, numbers stored as text, the formula sitting inside its own range, or an array instead of a range. The “why it returns 0” table above gives them in order.
Does COUNTIF work with dates? Yes — dates go in quotes like text: =COUNTIF(D2:D11, ">10/1/2026") counts the orders after 1 October 2026.
That is the COUNTIF formula in Excel: two parts, the range and the test, with one quoting rule to remember — text and comparisons go in double quotes, plain numbers and cell references do not. On the ten-row table in this guide, that one rule answers every question: four orders from the East (including the lowercase “east”), five sales over $1,000, eight orders after 1 October, three notes containing Rush, and four empty Notes cells. When one condition is not enough, COUNTIFS takes the same pattern and adds a second range and criteria — East and Paid is 3. And when the answer comes back 0, do not blame the function: check for a trailing space, numbers stored as text, or the formula sitting inside its own range. From here, the next functions worth learning are the ones this one sits next to — the count cells with text guide for the text-counting details, and the full learning order for the whole site is on the Excel Formulas hub and the Logical & Conditional category page.
Learn Excel comparison operators: equal, not equal, greater than, less than, and between two numbers, in IF, COUNTIF and SUMIF.
Read Guide →Learn how to shade every other row in Excel: the MOD formula, banded table rows, odd rows, every third row and filters.
Read Guide →Learn the Excel formula for if a cell contains specific text: ISNUMBER with SEARCH, FIND for case, and COUNTIF wildcards.
Read Guide →