All guides

COUNTIF and SUMIF in Excel

COUNTIF counts how many cells in a range meet a condition; SUMIF totals the values in a range where a related condition is true. They're two of the most-used formulas in everyday Excel work — anywhere you'd otherwise filter a list and eyeball a count, COUNTIF does it instantly and keeps recalculating as the data changes.

Worked example

=COUNTIF(A2:A20, "Closed")

Counts how many cells in A2:A20 contain the text "Closed"

SUMIF adds a third argument: =SUMIF(A2:A20, "Closed", B2:B20) sums column B wherever column A says "Closed".

Wildcards make COUNTIF much more flexible

COUNTIF and SUMIF both support * (any characters) and ? (one character) inside the criteria string — =COUNTIF(A2:A20, "North*") counts every cell starting with "North", including "North Region" and "Northwest".

This is the difference between a rigid exact-match formula and one that actually survives messy real-world data entry.

When you need more than one condition

COUNTIF and SUMIF each take exactly one condition. For two or more conditions at once — "Closed" AND "this month" — use COUNTIFS and SUMIFS instead, which take any number of range/criteria pairs.

Practice this for real

Try the "COUNTIF & SUMIF" exercises

Type the formula into a real spreadsheet and get instant feedback.

Related guides