ShareYourGroupShareYourGroupExcel Formulas

Statistical functions

COUNTIF function in Excel

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

COUNTIF answers "how many?" with a condition attached: how many students passed, how many orders are pending, how many times a name appears. Along with SUMIF, it is the function most used to summarise a list.

Syntax

=COUNTIF(range, criteria)
ArgumentWhat it is
rangeThe cells to look at.
criteriaThe condition: a value, a comparison in quotation marks, or a cell reference.

Examples

Each result below is what Excel itself showed for the formula on the sample sheet.

Sample sheet: Marks of eight students in three subjects. One Science mark is missing (cell D6 is empty).
ABCDE
1NameClassMathsScienceEnglish
2Asha8A788591
3Ravi8B455260
4Meena8A928879
5Kabir8B334138
6Tara8A6772
7Joy8B889084
8Neha8A546158
9Imran8B787369

How it works

COUNTIF looks at each cell of the range, tests it against the condition and counts the cells that pass. It has only two arguments, so there is nothing to line up.

Writing the condition

To countWrite
cells equal to a text"8A"
cells equal to a number78
cells above a number">75"
cells at or below a number"<=40"
cells not equal to something"<>Pen"
cells equal to the value in H1H1
cells above the value in H1">"&H1
text that starts with A"A*"
text that contains "kg""*kg*"
text of exactly four characters"????"
empty cells""
cells that are not empty"<>"

Two rules cover most mistakes. A comparison sign goes inside quotation marks. A cell reference stays outside them and is joined on with &.

Text matching ignores capital and small letters.

Finding duplicates

COUNTIF is the standard tool for spotting repeated values.

Is this value in that list?

=COUNTIF(list, A2)>0 is TRUE when A2 appears in the list. Put it beside one list to check each entry against another. It is the simplest way to compare two lists.

A percentage

Divide by the total count for a share: =COUNTIF(C2:C9,">=33")/COUNT(C2:C9) is the pass rate. Format the cell as a percentage.

Counting within bands

For "from 40 up to 59" you need two conditions, which is COUNTIFS. With COUNTIF alone, subtract: =COUNTIF(C2:C9,">=40")-COUNTIF(C2:C9,">=60").

Limits and surprises

In Google Sheets

COUNTIF is the same in Google Sheets.

Related functions

Every result on this page was calculated in Microsoft Excel (version 16.0, build 20326) on 12 November 2026, not typed by hand.

This is an independent help site. It is not connected with or approved by Microsoft. Excel and Microsoft 365 are trademarks of Microsoft Corporation, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.