← All how-to recipes

How to count how many times a value appears in a range

✓ Verified in LibreOffice 25.8.7.3

Count the number of cells in a range that exactly match a given value.

The formula

AppFormulaNotes
Excel=COUNTIF(A2:A7,"apple")COUNTIF counts cells equal to the criterion.
Google Sheets=COUNTIF(A2:A7,"apple")Identical.
LibreOffice Calc=COUNTIF(A2:A7,"apple")Identical.

How it works

COUNTIF(range, criterion) returns how many cells in the range match the criterion. Here 'apple' appears in A2, A4 and A6, so the result is 3. Use a cell reference (e.g. =COUNTIF(A2:A7,C1)) to make the searched value dynamic.

Verified, not just documented

We ran =COUNTIF(A2:A7,"apple") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 3 — exactly the expected result. Every formula here is confirmed by actually executing it.