This syntax takes a little getting used to.

See below for many working examples.

When cells meet the criteria, they are added to the count.

COUNTIF function - basic example

In the worksheet below, we have a small amount of sales data.

The tricky part about using the COUNTIF function is the syntax needed to apply criteria.

This is because COUNTIF is in a group ofeight functionsthat split logical criteria into two parts:rangeandcriteria.

COUNTIF function - basic example

Because of this design, operators must be enclosed in double quotes ("").

This makes it easy to change criteria later without editing the original formula.

Notice the greater than operator (>), which is text, must be enclosed in quotes.

COUNTIF function - basic example

The most reliable method is to refer to a date in another cell or use theDATE function.

to match a question mark (?)

that occurs at the end of “Michigan?”

COUNTIF function - basic example

and “Montana?”.

The tilde (~) is an escape character that allows you to find aliteralwildcard.

To match a question mark (?

COUNTIF function - basic example

), use “~?

Summary Table

you’re able to use COUNTIF to create a simple summary table of counts.

In the worksheet below, we have a list of unique colors in F5:F9.

COUNTIF function example - criteria in another cell

The goal is to generate a count for each color.

For more advanced users, this is an important limitation in how COUNTIF works and what it can do.

One of the more tricky limitations of COUNTIF is that it won’t allow anarrayfor therangeargument.

COUNTIF function example - not equal to

This would be cool if it worked.

However, Excel won’t even let you enter this formula.

If you try, you’ll get a generic “There’s a problem with your formula” error.

COUNTIF function example - count blank and not blank cells

However, SUMIF is not programmed to handle arrays, so it won’t work.

How can we work around this problem?

However, the latest version of Excel offers powerful alternatives, includingBYROW,BYCOL, andGROUPBY.

COUNTIF function example - working with dates

Numbers include negative numbers, percentages, dates, times, fractions, and formulas that return numbers.

COUNTA does not count empty cells.

COUNTIF function example - working with wildcards

COUNTIF function example - creating a simple summary table

COUNTIF function example - the “array problem”

COUNTIF function example - workaround for the array problem

Excel formula: Text is greater than number

Excel formula: Highlight unique values

Excel formula: Range contains one of many substrings

Excel formula: Count cells that contain text

Excel formula: Highlight cells that begin with

Excel formula: Range contains duplicates

Excel formula: Count cells not equal to

Excel formula: First match between two ranges

Excel formula: Count cells greater than

Excel formula: Student class enrollment with table

Excel formula: Search multiple worksheets for value

Excel formula: Basic text sort formula

Excel formula: Count cells that contain positive numbers

Excel formula: Count total matches in two ranges

Excel formula: Validate input with check mark

Article image

Article image

Article image

Article image

Article image

Article image

Article image

Article image

Excel COUNTIF function

Excel COUNTIFS function

Excel COUNT function

Excel COUNTA function

COUNTIF function - basic example

COUNTIF function example - criteria in another cell

COUNTIF function example - not equal to

COUNTIF function example - count blank and not blank cells

COUNTIF function example - working with dates

COUNTIF function example - working with wildcards

COUNTIF function example - creating a simple summary table

COUNTIF function example - the “array problem”

COUNTIF function example - workaround for the array problem