This tutorial shows how to Count cells between two numbers in Excel using the example below;
To count the number of cells that contain values between two numbers in a range of cells, you can use the COUNTIFS function. In the example above X represents the lower boundary, and Y represents the upper boundary of the numbers you want to count.
In the example, the active cell contains this formula:
How this formula works
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.
Using COUNTIF instead
If you have an older version of Excel that doesn’t have the COUNTIFS function, you can use the COUNTIF function instead like this:
The first COUNTIF counts the number of cells in a range that are greater than or equal to X (which by definition also includes values greater than Y, since Y is greater than X). The second COUNTIF counts the number of cells with values greater than Y. This second number is then subtracted from the first number, which yields the final result – the number of cells that contain values between X and Y.
Making the criteria variable
If you want to use a value in another cell as part of the criteria, use the ampersand (&) character to concatenate like this:
If the value in cell a1 is “5”, the criteria will be “>5” after concatenation.