# How to use COUNTIF function in Excel

MS Excel: How to use the COUNTIF Function (WS)This Excel tutorial explains how to use the Excel COUNTIF function with syntax and examples.DescriptionThe Microsoft Excel COUNTIF fun

## MS Excel: How to use the COUNTIF Function (WS)

This Excel tutorial explains how to use the Excel **COUNTIF function** with syntax and examples.

## Description

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

The COUNTIF function is a built-in function in Excel that is categorized as a Statistical Function. It can be used as a worksheet function (WS) in Excel. As a worksheet function, the COUNTIF function can be entered as part of a formula in a cell of a worksheet.

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

Subscribe

If you want to follow along with this tutorial, download the example spreadsheet.

Download Example

## Syntax

The syntax for the COUNTIF function in Microsoft Excel is:COUNTIF( range, criteria )

### Parameters or ArgumentsrangeThe range of cells that you want to count based on the criteria.criteriaThe criteria used to determine which cells to count.

## Returns

The COUNTIF function returns a numeric value.

## Applies To

- Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

## 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:

Based on the Excel spreadsheet above, the following COUNTIF examples would return:=COUNTIF(A2:A7, D2) Result: 1 =COUNTIF(A:A, D2) Result: 1 =COUNTIF(A2:A7, ">=2001") Result: 4

## Using Named Ranges

You can also use a named range in the COUNTIF function. A named range is a descriptive name for a collection of cells or range in a worksheet. If you are unsure of how to setup a named range in your spreadsheet, read our tutorial on Adding a Named Range.

For example, we've created a named range called family that refers to **column A** in Sheet 1.

Then we've entered the following data in 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.

## 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:=COUNTIF(A2,A5,F6,G9,">0")

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

For example:=SUM(COUNTIF(A2,">0"),COUNTIF(A5,">0"),COUNTIF(F6,">0"),COUNTIF(G9,">0"))

OR=COUNTIF(A2,">0")+COUNTIF(A5,">0")+COUNTIF(F6,">0")+COUNTIF(G9,">0")

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

For example:=COUNTIF(C4:C19,">=2/26/04")

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:=COUNTIF(C4:C19,">="&A1)

Question:I would like to do the following:=COUNTIF(ABS(A1:A10),">0")

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:=COUNTIF(A1:A10,">0")+COUNTIF(A1:A10,"<0")

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