Share this page:

MS Excel: COUNTIF Function (WS)

Learn how to use the Excel COUNTIF function with syntax and examples.


The Microsoft Excel COUNTIF function counts the number of cells in a range, that meets a given criteria.

If you wish to apply multiple criteria, try using the COUNTIFS function.


The syntax for the Microsoft Excel COUNTIF function is:

COUNTIF( range, criteria )

Parameters or Arguments

range is the range of cells that you want to count based on the criteria.

criteria is used to determine which cells to count.

Applies To

The COUNTIF function can be used in the following versions of Microsoft Excel:

  • Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Excel Function

The COUNTIF function can be used in Microsoft Excel as the following type of function:

  • Worksheet function (WS)

Example (as Worksheet Function)

Let's look at some Excel COUNTIF function examples and explore how to use the COUNTIF function as a worksheet function in Microsoft Excel:

Microsoft Excel

Based on the spreadsheet above, the following Excel COUNTIF examples would return:

Result: 1

Result: 1

=COUNTIF(A2:A7, ">=2001")
Result: 4

Using Named Ranges

You can also use a named range in the COUNTIF function. For example, we've created a named range called family that refers to column A in Sheet 1.

Microsoft Excel

Then we've entered the following data in Excel:

Microsoft Excel

Based on the Excel spreadsheet above:

=COUNTIF(family, D2)
Result: 1

=COUNTIF(family, ">=2001")
Result: 4

To view named ranges: Under the Insert menu, select Name > Define.

Microsoft Excel

Frequently Asked Questions

Question: I'm trying to use COUNTIF on a selection of cells (not necessarily one solid range), and the syntax of the function does not allow that. Is there another way to do this?

Here's an example of what I'd like to be able to do:


Answer: Unfortunately, the COUNTIF function does not support multiple ranges. However, you could try summing multiple COUNTIFs.

For example:




Question: I am using the COUNTIF function and I would like to make the criteria equal to a cell.

For example:


I want to replace 2/26/04 with cell A1. How do I do this?

Answer: To use a cell reference in the criteria, you could do the following:


Question:I would like to do the following:


i.e. count the number of values in the range A1:A10 that have a non-zero magnitude. The syntax I tried does not work. Could you help?

Answer: Because you can not apply the ABS function to range A1:A10, you will need to instead break up your formula into two COUNTIF functions as follows:


This will count the number of values that are either greater than 0 or less than 0.