Bookmark and Share

This short Excel tip shows how to use Excel's COUNTIF function to count the number of data points between two values. Listed below are the various conditions, and the corresponding formulas using the COUNTIF function. The trick is simply to subtract one condition from the other.

To download a sample spreadsheet containing these COUNTIF formulas using some made-up data, click here: countif-example.xls. This example shows how the formulas can be made a little more dynamic, by concatenating the conditional operator (<, <=, >, >=, <>) with a cell reference.

The data for the following formulas would be contained in column A.
Condition Formula
1 < x < 4 =COUNTIF(A:A,"<4")-COUNTIF(A:A,"<=1")
1 <= x < 4 =COUNTIF(A:A,"<4")-COUNTIF(A:A,"<1")
1 < x <= 4 =COUNTIF(A:A,"<=4")-COUNTIF(A:A,"<=1")
1 <= x <= 4 =COUNTIF(A:A,"<=4")-COUNTIF(A:A,"<1")

References

Cite This Article

To reference this article from your website or blog, please use something similar to the following citation:

Wittwer, J.W., "Excel COUNTIF Formulas for Two Conditions" From Vertex42.com, Janurary 15, 2005, http://www.vertex42.com/ExcelTips/excel-countif-function.html

Disclaimer: This article is meant for educational purposes only.
 

Create Excel Dashboard Reports with Plug-N-Play Reports