The Excel COUNTIFS Function

Function Description

The Excel Countifs function returns the number of rows within a table, that satisfy a set of given criteria.

The function is new in Excel 2007, and so is not available in earlier versions of Excel.

The syntax of the Countifs function is:

COUNTIFS( criteria_range1, criteria1, [criteria_range2, criteria2], ... )

Where the function arguments are as follows:

[criteria_range2], ...

Arrays of values (or ranges of cells containing values) to be tested against the respective criteria1, [criteria2], ...

(The supplied criteria_range arrays must all have the same length).

[criteria2], ...
-The conditions to be tested against the values in criteria_range1, [criteria_range2], ...

Up to 127 pairs of criteria_range and criteria arguments can be supplied to the function.


The Countifs function allows the use of the following wildcards in text-related criteria:

?    -    matches any single character
*    -    matches any sequence of characters

if you do actually want to find the ? or * character, type the ~ symbol before this character in your search.

E.g. the condition "A*e" will match all cells containing a text string beginning with "A" and ending in "e".

Each of the supplied criteria can be either:


Note that if your criteria is a text string or an expression, this must be supplied to the function in quotes.

Also note that the Excel Countifs function is not case-sensitive. So, for example, the text strings "TEXT" and "text" will be evaluated as equal.

Excel Countifs Function Examples

The spreadsheet below shows a set of exam results for a class of students.

The Countifs function can be used to find the number of rows in the data set that satisfy conditions relating to the subject, score and gender.

This is shown in the examples below.


Example 1

If we want to know how many female test scores were greater than 60%, we could use the following formula:

=COUNTIFS( B2:B13, "Female", D2:D13, ">60%" )

which gives the result 4.

In this example, the formula has counted the number of rows where:


Example 2

If we want to know how many science tests scores were less than 50%, we could use the formula:

=COUNTIFS( C2:C13, "Science", D2:D13, "<50%" )

which gives the result 2.

For further examples of the Excel Countifs function, see the Microsoft Office website.

Countifs Function Error

If you get an error from the Excel Countifs function, this is likely to be the #VALUE! error:

Common Error

Occurs if either:

  • The supplied criteria_range arrays do not all have equal length
  • Any of the supplied criteria arguments are text strings that are greater than 255 characters long.