formulastreak

Conditional totals function

COUNTIF function in Google Sheets and Excel

COUNTIF counts the cells in a range that meet one condition.

Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet

Syntax

COUNTIF(range, criteria)

Arguments in [brackets] are optional. Google Sheets writes it COUNTIF(range, criterion).

Example

=COUNTIF(B2:B9,"North") reads: Count the cells in the region column B2:B9 that say North.

Q3 sales team · edit I1 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultI1 = 2
ABCDEFGHI
1RepRegionJulAugSepTargetNorth reps2
2Amara OseiNorth$12,400$13,100$11,800$36,000
3Ben FischerSouth$9,800$10,250$12,100$30,000
4Lina ChenEast$15,200$14,800$16,900$45,000
5Diego AlvarezWest$8,700$9,100$8,400$28,000
6Eva NovakNorth$11,200$12,600$13,900$36,000
7Farid HaddadSouth$13,300$12,900$14,100$39,000
8Grace KimEast$10,100$9,600$10,800$33,000
9Hugo MartinWest$14,500$15,800$15,100$42,000

I1 shows 2: Amara and Eva are the two North reps.

How the spreadsheet calculates it

Counts the cells in B2:B9 whose value is equal to "North".

  1. 1. COUNTIF: Counts the cells in B2:B9 whose value is equal to "North".
    • range = `B2:B9`: the cells to check
    • criteria = `"North"`: what to count

More COUNTIF examples

  • =COUNTIF(B2:B9,"North")How many reps are in the North.
  • =COUNTIF(F2:F13,">="&K1)How many orders have at least the quantity in K1.
  • =COUNTIF($A$2:$A$11,A2)>1TRUE for a value that appears more than once.
  • =COUNTIF(A2:A20,"<>")How many cells aren't empty.

Paste any of these into the formula explainer to see it step by step.

Tips

  • Use $ on the range when filling down, or each row counts a shifted range.
  • Join comparisons with & (">="&K1) instead of typing the cell inside quotes.
  • For several conditions, switch to COUNTIFS rather than nesting or adding COUNTIFs.
  • For “contains”, put wildcards around the text: "*pot*" counts every cell with pot anywhere in it.

What COUNTIF is used for

Counting orders per status, attendees per city or tickets per agent, finding duplicates (a count above 1), and checking that an entry exists in a list.

Arguments

ArgumentRequiredWhat it is
rangeYesThe cells to check.
criteriaYesThe condition: a number, text in quotes, a comparison in quotes like ">32", a cell like B4, or a wildcard pattern.Watch out: A cell inside the quotes (">K1") is read as text.

Common mistakes

  • Unquoted comparisons: COUNTIF(F2:F13,>2) won't calculate.

  • Expecting it to match case: “north” and “NORTH” count the same.

  • Matching text longer than 255 characters, which Microsoft says gives wrong results.

In Google Sheets

Google Sheets' COUNTIF reads criteria the same way, with the same * and ? wildcards and ~ to match them literally.

Errors you may see with COUNTIF

  • #VALUE!: The range is in another workbook that's closed.

Questions

How do I count with more than one condition?

Use COUNTIFS. See COUNTIF vs COUNTIFS.

How do I count cells that contain a word?

Wildcards on both sides: COUNTIF(A2:A20, "*pot*"), or from a cell, "*"&K1&"*". See COUNTIF with a cell reference.

How do I count blank cells?

COUNTIF(range, "") counts empty cells; COUNTBLANK does the same job.

Can COUNTIF count by color?

No: COUNTIF tests values, not formatting. Count by the rule behind the color instead (the same condition you used for conditional formatting).

Does COUNTIF count numbers stored as text?

A criteria like ">10" compares numbers, so a value imported as text doesn't pass it. Convert the column with VALUE first; lookup numbers stored as text shows how to tell which cells are text.

What's the difference between COUNT, COUNTA and COUNTIF?

COUNT counts cells holding numbers, COUNTA counts every non-empty cell, and COUNTIF counts the cells that meet a condition you choose. See SUM, AVERAGE and COUNT.

Sources

Official documentation the facts on this page were checked against.

Practise COUNTIF on a live sheet

Lesson 20, COUNTIF, AVERAGEIFS and MAXIFS (Unit 5, Conditional totals), has 6 graded exercises, checked instantly, with steps and hints when you're stuck. Pro