← All how-to recipes

How to use the COUNTIF function

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Count how many cells meet a condition — how many times a value appears, how many pass a threshold.

The formula

AppFormulaNotes
Excel (desktop)=COUNTIF(A2:A10,"East")COUNTIF(range, criteria). Comparisons and wildcards go in the quoted criteria.
Google Sheets=COUNTIF(A2:A10,"East")Identical.
LibreOffice Calc=COUNTIF(A2:A10,"East")Identical.

How it works

COUNTIF takes just two things: the range to look through (A2:A5) and the criteria to count ("East") — here it finds "East" three times. The criteria is flexible: a number, exact text, a comparison in quotes (">100" counts values over 100), or wildcards ("E*" counts anything starting with E, "?at" matches cat/bat/hat). Two everyday uses: flag duplicates with =COUNTIF(range,cell)>1, and check membership with =COUNTIF(list,value)>0. For more than one condition use COUNTIFS, and to count blanks or non-blanks use COUNTBLANK or COUNTA.

Verified, not just documented

We ran =COUNTIF(A2:A5,"East") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 3 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 3 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

COUNTIF — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons