How to Use COUNTIF Between Two Numbers (4 Methods)

The COUNTIF Function in Excel: Syntax

➤ Description

Count cells within specific criteria.

➤ Generic Syntax

COUNTIF(range,criteria)

➤ Argument Description

ARGUMENT REQUIREMENT EXPLANATION
range  Required The number of cells we want to count according to the criteria.
criteria  Required The criteria that we will use to determine which cells to count.

➤ Returns

The return value of the COUNTIF function is numeric.

➤ Available in

Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000.


Method 1 – Using the COUNTIF Function to Count Cell Numbers Between Two Numbers

We have a dataset of 6 students with their marks. We will count how many students have the marks that fulfill the following conditions: ‘>=70’ and ‘<80. These conditions are placed as strings in two cells.

Use of COUNTIF Function to Count Cell Numbers Between Two Numbers

  • Select cell F7.
  • Insert the following formula:
=COUNTIF(C5:C10,">="& 70)
  • Press Enter.

Use of COUNTIF Function to Count Cell Numbers Between Two Numbers

  • Insert the following formula in cell F8:
=COUNTIF(C5:C10,"<"& 80)
  • Press Enter.
  • Finally, this will return the number of students 3 in cell F8.

Read More: COUNTIF Function to Count Cells That Are Not Equal to Zero


Method 2 – Using the COUNTIF Formula between Two Number Ranges

We will use the dataset of our previous example. We’ve inserted other conditions as text in the result table.

COUNTIF Formula with Two Number Ranges

  • Select cell F7.
  • Insert the following formula:
=COUNTIF(C5:C10,">="&C12)-COUNTIF(C5:C10,">="&C13)
  • Press Enter. This returns the number of total students with marks in the range >=50 and <=80, which is 3.

COUNTIF Formula with Two Number Ranges

  • Insert the following formula in cell F8:
=COUNTIF(C5:C10,">="&40)-COUNTIF(C5:C10,">="&60)
  • Use this formula in cell F9:
=COUNTIF(C5:C10,">="&70)-COUNTIF(C5:C10,">="&90)
  • Here are our results.

How Does the Formula Work?

  • COUNTIF(C5:C10,”>=”&C13): Calculates the number of students with more than 80 marks.
  • COUNTIF(C5:C10,”>=”&C12): This part gives the student’s count who got more than 50 marks.
  • COUNTIF(C5:C10,”>=”&C12)-COUNTIF(C5:C10,”>=”&C13): Returns the total count of students within the range >=50 & >=80.

Read More: Apply COUNTIF Function in Multiple Ranges for Same Criteria


Similar Readings


Method 3 – Applying the Excel COUNTIF Function Between Two Dates

We have a dataset of dates with corresponding sales data. We are going to count the dates between two dates as well as for a single date.

Apply COUNTIF Function Between Two Dates

  • Select cell F7.
  • Insert the following formula:
=COUNTIF(B5:B10,">="&C12)
  • Hit Enter.

Apply COUNTIF Function Between Two Dates

  • Put the below formula in cell F8:
=COUNTIF(B5:B10,">="&C12)-COUNTIF(B5:B10,">="&C13)
  • Press Enter.

How Does the Formula Work?

  • COUNTIF(B5:B10,”>=”&C13): Counts the number of dates less than the value of cell C13.
  • COUNTIF(B5:B10,”>=”&C12): Finds the total number of dates less than cell C12.
  • COUNTIF(B5:B10,”>=”&C12)-COUNTIF(B5:B10,”>=”&C13): Returns the number of dates within the range  >=10-01-22 and <=12-01-22.

Read More: COUNTIF Between Two Dates in Excel (4 Suitable Examples)


Method 4 – Applying the COUNTIF Function to Count a Particular Time Between Two Numbers

In the following figure, we have 3 time ranges. Let’s calculate the number of dates for each time range.

COUNTIF Function to Count a Particular Time

  • Select the cell G7.
  • Insert the following formula:
=COUNTIF(C5:C10,">="&F7)
  • Press Enter.

COUNTIF Function to Count a Particular Time

  • Put the formulas given below in cells H8 and H9.
  • For H8:
=COUNTIF(C5:C10,">="&F8)
  • For H9:
=COUNTIF(C5:C10,"<="&F8)
  • Here are our results.

Read More: How to Use Excel COUNTIF Between Time Range (2 Examples)


Download the Practice Workbook


Further Readings

Get FREE Advanced Excel Exercises with Solutions!
Mukesh Dipto
Mukesh Dipto

Mukesh Dipto is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including Rhino3D, Maxsurf C++, AutoCAD, HTML, CSS, JavaScript, and WordPress. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he... Read Full Bio

2 Comments
  1. There seems to be a logical error when counting cells with values between two given numbers.
    The result “3”, pshowed in the students’ marks example (>=50 and <=80) should be 4…

    • Thanks for your feedback sir.
      The range is (>=50 and <=80). In Excel COUNTIF function by default omit the upper end value.
      So, the formula is basically showing the result for the values less than 80.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo