Home  /  Blog  /  Logical & Conditional
Logical & Conditional

COUNTIF Formula in Excel — With Examples (and COUNTIFS)

By admin 1 December 2026 Logical & Conditional

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.
  • Text and comparisons go in quotes: "East", ">1000". Plain numbers and cell references do not: 1200, G2.
  • COUNTIF ignores case: "East" matches east and EAST.
  • One condition only. Two conditions need COUNTIFS.
COUNTIF Formula in Excel — With Examples (and COUNTIFS)

The Formula — Two Parts

=COUNTIF(range, criteria)
PartWhat it does
rangeThe group of cells Excel looks through — a column, a row, a block, or a named range
criteriaThe 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.

The Worked Table — One Table for Every Example

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.

RowA: RepB: RegionC: SalesD: Order DateE: StatusF: Notes
2AlexEast12009/3/2026PaidRush
3PriyaWest8509/15/2026Pending
4Jordaneast240010/2/2026PaidGift wrap
5SamNorth45010/9/2026PaidCall first
6AlexWest175010/20/2026Pending
7TaylorEast60010/22/2026PaidRush
8PriyaEast90011/4/2026Pending
9JordanSouth110011/12/2026PaidDelivery
10SamWest30011/20/2026Pending
11AlexNorth150012/1/2026PaidRush

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.

Count Cells That Match Specific Text

The most common use. The text goes in double quotes, and COUNTIF ignores case.

GoalFormulaResult
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.

Count Cells by Number — Greater Than, Less Than, Equal To

Numbers work the same way, but a comparison needs quotes around the operator and the number together.

GoalFormulaResult
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.

Count Cells by Date — Before or After a Cutoff

Dates are criteria in quotes, just like text. Excel compares the date in the cell with the date in the quotes.

GoalFormulaResult
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.

Wildcards — Count Cells That Contain a Word

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.

GoalFormulaResult
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.

Count Blanks — and Count Non-Blanks

Blank cells have their own criteria. An empty pair of quotes counts the blanks; "<>" counts everything that is not blank.

GoalFormulaResult
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.

Use a Cell Reference as the Criteria

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.

Two Conditions — COUNTIFS

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.

GoalFormulaResult
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.

COUNT, COUNTA, COUNTIF, COUNTIFS — Which One?

Four functions that all count, and the difference is what they count.

FunctionCountsExample on this table
COUNTNumbers only=COUNT(C2:C11) → 10
COUNTAEvery non-empty cell=COUNTA(F2:F11) → 6
COUNTIFCells passing one condition=COUNTIF(B2:B11, "East") → 4
COUNTIFSCells passing two or more conditions=COUNTIFS(B2:B11, "East", E2:E11, "Paid") → 3
COUNTBLANKEmpty 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.

Why COUNTIF Returns 0 — Four Checks

The most common failure, and it is almost never the function. Work through these in order.

CheckWhat happensFix
A trailing spaceThe 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 textThe cell shows 1200 but holds text, so =COUNTIF(C2:C11, 1200) finds nothingConvert the column to numbers first (Paste Special → Multiply by 1)
The formula sits inside its own rangePutting the formula in B12 while counting B2:B12 creates a circular referencePut the formula outside the range it counts
An array instead of a rangeCOUNTIF requires an actual range — it will not accept an arrayPoint it at real cells, not an array expression

Common Mistakes

MistakeWhat happensFix
You wrote >1000 without quotesExcel will not accept the formulaPut 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 conditionsIt counts only the first condition, or errorsUse 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 highThat is correct behaviour — check for a lowercase twin, or use an exact-match helper
You counted the heading rowThe heading “Region” got counted as a valueStart the range at row 2, not row 1

Frequently Asked Questions

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.


About admin

Author of Excel formula guides on this blog.

View all guides by admin →

Keep Learning

Related guides