COUNTIF

Count how many cells in a range satisfy one condition.

Syntax

COUNTIF(range, criteria)
Argument Required Description
range Required The cells to test.
criteria Required The condition — "East", 100, ">400", or a wildcard pattern like "E*".

Examples

Every example below was executed against VisiGrid engine 0.35.0 — not transcribed from another vendor's documentation. Reproduce any of them with vgrid calc.

Formula Result Notes
=COUNTIF(B2:B4,"East") 2 Two rows are in the East region.
=COUNTIF(B2:B4,"E*") 2 Wildcards work in criteria — asterisk for any characters, question mark for one.
=COUNTIF(D2:D4,">400") 2 Comparison operators go inside the quoted criteria.
=COUNTIF(A2:A2,"102") 1 Criteria are a small pattern language, not a lookup key — numeric-looking criteria compare numerically. Expected to stay when lookups go strict.

Operators live inside the quotes

This trips people up more than it should. The comparison is part of the criteria string, not something you write around it:

=COUNTIF(D2:D4, ">400")     ← correct
=COUNTIF(D2:D4 > 400)       ← not a thing

To compare against a cell rather than a literal, join the operator to the reference: ">" & F1.

Edit the criteria below — try >400, then <400, then 700, then >=300. SUMIF reads the same criteria, which is why the two are worth learning together:

Criteria go in one cell; both formulas read it.
Item Sales
Widget 500
Gadget 700
Doohickey 300
Criteria: >400
Count: 2
Total: 1200

Edit the highlighted cell and the formula recalculates — computed by VisiGrid engine 0.35.0, in your browser. Nothing is saved.

Checking whether something exists

COUNTIF is the tidiest way to ask “is this value in that list”, because it returns 0 rather than an error when nothing matches:

=IF(COUNTIF(A2:A100, "Bo") > 0, "found", "not found")

That avoids wrapping a lookup in IFERROR just to find out whether it would have failed — and unlike IFERROR, it cannot accidentally hide a broken range.

Counting duplicates

Counting each value against its own column tells you which entries repeat. A result above 1 means the value appears more than once, which is usually how duplicate keys get found before they corrupt a lookup.

Excel compatibility

Matches Excel, including comparison operators and wildcards in criteria.

Related functions

Last updated