### Syntax

The syntax for the COUNTIFS function depends on the criteria being evaluated. Each separate condition will require a range and a criteria. The generic syntax looks like this: The first two arguments, range1 and criteria1 are required. Range1 is the range to which criteria1 should be applied. Range2 is the range to which criteria2 should be applied. Additional conditions are applied by providing more range and criteria arguments: the third condition is defined by range3 and criteria3, the fourth condition is defined by range4 and criteria4, and so on. When using COUNTIFS, keep the following in mind:

To be included in the final result, all conditions must be TRUE. All ranges must be the same size or COUNTIFS will return a #VALUE! error. Criteria should include logical operators (>,<,<>,<=,>=) as needed. Each new condition requires a separate range and criteria.

### Criteria

The COUNTIFS function supports logical operators (>,<,<>,=) and wildcards (*,?) for partial matching. Because COUNTIFS is in a group of eight functions that split logical criteria into two parts, the syntax is a bit tricky. Each condition requires a separate range and criteria, and operators need to be enclosed in double quotes (""). The table below shows some common examples: Notice the last two examples use concatenation with the ampersand (&) character. When a criteria argument includes a value from another cell, or the result of a formula, logical operators like “<” must be joined with concatenation. This is because Excel needs to evaluate cell references and formulas first to get a value before that value can be joined to an operator.

### Basic example

With the example shown, COUNTIFS can be used to count records using 2 criteria as follows: Notice the COUNTIFS function is not case-sensitive.

### Double quotes ("") in criteria

In general, text values need to be enclosed in double quotes, and numbers do not. However, when a logical operator is included with a number, the number and operator must be enclosed in quotes as shown below: Note: showing one condition only for simplicity. Additional conditions must follow the same rules.

### Value from another cell

When using a value from another cell in a condition, the cell reference must be concatenated to an operator when used. In the example below, COUNTIFS will count the values in A1:A10 that are less than the value in cell B1. Notice the less than operator (which is text) is enclosed in quotes, but the cell reference is not: Note: COUNTIFS is one of several functions that split conditions into two parts: range + criteria. This causes some inconsistencies with respect to other formulas and functions.

### Not equal to

To construct “not equal to” criteria, use the “<>” operator surrounded by double quotes (""). For example, the formula below will count cells not equal to “red” in the range A1:A10:

### Blank cells

COUNTIFS can count cells that are blank or not blank. The formulas below count blank and not blank cells in the range A1:A10:

### Dates

The easiest way to use COUNTIFS with dates is to refer to a valid date in another cell with a cell reference. For example, to count cells in A1:A10 that contain a date greater than a date in B1, you can use a formula like this: Notice we concatenate the “>” operator to the date in B1, but and are no quotes around the cell reference. The safest way to hardcode a date into COUNTIFS is with the DATE function. This guarantees Excel will understand the date. To count cells in A1:A10 that contain a date less than September 1, 2020, you can use:

### Wildcards

The wildcard characters question mark (?), asterisk(*), or tilde (~) can be used in criteria. A question mark (?) matches any one character, and an asterisk (*) matches zero or more characters of any kind. For example, to count cells in A1:A5 that contain the text “apple” anywhere, you can use a formula like this:
The tilde (~) is an escape character to allow you to find literal wildcards. For example, to count a literal question mark (?), asterisk(*), or tilde (~), add a tilde in front of the wildcard (i.e. ~?, ~*, ~~).

### OR logic

The COUNTIFS function is designed to apply multiple criteria, but conditions are applied with AND logic. This means if you try to count cells that contain “red” or “blue” in the same range, the result will be zero (0). However, to count cells with OR logic, you can use an array constant and the SUM function like this: The formula above will count cells in range that contain “red” or “blue”. Briefly, COUNTIFS returns two counts in an array (one for “red” and one for “blue”) and the SUM function returns the sum as a final result. For more information, see this example.

### Limitations

The COUNTIFS function has some limitations you should be aware of:

Conditions in COUNTIFS are joined by AND logic. In other words, all conditions must be TRUE in order for a cell to be included in a count. The workaround above can be used in simple situations. The COUNTIFS function requires actual ranges for all range arguments; you can’t use an array. This means you can’t alter values that appear in a range argument before applying criteria. COUNTIFS is not case-sensitive. To count values based on a case-sensitive condition, you can use a formula based on the SUMPRODUCT function with the EXACT function. COUNTIFS has some other quirks, which are detailed in this article.

The most common way to work around the limitations above is to use the SUMPRODUCT function. In the current version of Excel, another option is to use the newer BYROW and BYCOL functions.

### Notes

Multiple conditions are applied with AND logic, i.e. condition 1 AND condition 2, etc. All ranges must be the same size. If you supply ranges that don’t match, you’ll get a #VALUE error. Non-numeric criteria must be enclosed in double quotes (i.e. “<100”, “>32”, “TX”). The wildcard characters ? and * can be used in criteria. A question mark matches any one character and an asterisk matches any sequence of characters. To match a literal question mark(?) or asterisk (*), use a tilde (~) like (~?, ~*).

### Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.