How to Use the COUNTIF Function to Count Cells Between Two Numbers

Using the COUNTIFS Between Two Values

Using the Countifs function you can achieve the result of counting numbers of cells which contain values between two numbers in a range.

The Countifs function can show the count of cells that meet your criteria. You can use Countif with criteria using dates, numbers, text and other conditions.

Using Countifs you also need to use logical operators (>,<,<>,=).

The Countifs function is built to count cells that meet multiple criteria. In this case, because we supply the same range for two criteria, each cell in the range must meet both criteria in order to be counted.

Generic formula :

=COUNTIFS(range,">=X",range,"<=Y")

Use >= for greater than or equal to

Use <= for less than of equal to

So if we want to count based on criteria : Between 80 and 90 in our table

We use this formula : =COUNTIFS(B2:B9,">=80",B2:B9,"<=90") and the result should be 4 ( including : 82, 86, 81 and 90 )

Using COUNTIFS between dates

The following Countifs formula shows this idea by counting the number of dates that fall between a start and end date. The following formula counts the number of dates in A2:A9 that are equal to or greater than the date in E1 and equal to or less than the date in E2:

To count the number of cells that contain dates between two dates, you can use the Countifs function:

=COUNTIFS(range,">="&date1,range,"<="&date2)

=COUNTIFS($B$2:$B$9,">="&$E$1,$B$2:$B$9,"<="&$E$2)

So dates between 11/07/14 and 11/11/14 are found 5 dates, from B2 cell to B7 cell.

The COUNTIFS formula with multiple criteria

Suppose you have a product list like in the example below, and you want to get a count of items that are in stock (value in column B is greater than 0) but have not been sold yet (value is column C is equal to 0).

The task can be accomplished by using this formula:

=COUNTIFS(B2:B7,">0", C2:C7,"=0")

And the count is 2 (“Cherries” and “Lemons”)

When you want to count items with identical criteria, you still need to supply each criteria_range / criteria pair individually.

For example, here’s the right formula to count items that have 0 both in column B and column C:

=COUNTIFS($B$2:$B$7,"=0", $C$2:$C$7,"=0")

This COUNTIFS formula returns 1 because only “Grapes” have “0” value in both columns.

Different problems have their own best solution. If you are stuck and want to get to the solution quick, ask your question to have it answered by an Excel expert in 20 minutes. They are available to help you 24/7 at the link to the right. The first question is free.

Our customers love us!
“The expert was absolutely amazing and stuck with me the whole way through. They were polite, patient, seemed to want to genuinely help me and provided a solution that I would never have managed otherwise. I could not be more thankful for their support and solution. Thank you!” - - Chris T, in California

Leave a Comment

avatar