ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. COUNTIF Between Two Numbers in Excel

COUNTIF Between Two Numbers in Excel

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To count values between two numbers, use COUNTIFS with two conditions on the same range: =COUNTIFS(B2:B8,">=30",B2:B8,"<=45"). A cell is counted only when it meets both, so this counts values from 30 to 45, including both limits. Use ">" and "<" instead to leave the limits out. In very old Excel, subtract two COUNTIFs.

Key takeaways

  • COUNTIF takes one condition, so use COUNTIFS with the same range twice for a between count.
  • = and <= include the limits; > and < leave them out.

  • With limits in cells, join them with &: ">="&E1 and "<="&F1.
  • COUNTIF(range,">=30")-COUNTIF(range,">45") gives the same answer with plain COUNTIF.
  • You can't put both limits in one criteria like "30-45" or ">=30<=45".
On this page+
  1. Why COUNTIF alone can't count between two numbers
  2. How to count between two numbers with COUNTIFS
  3. Including or excluding the limits
  4. How to use limits stored in cells
  5. The subtraction method with COUNTIF
  6. How to count values in bands
  7. Between two dates and other variations
  8. How to count values outside a range
  9. Practise it

To use COUNTIF between two numbers, you actually need its bigger sibling, COUNTIFS, with two conditions on the same range: =COUNTIFS(B2:B8,">=30",B2:B8,"<=45"). One condition sets the lower limit and the other sets the upper limit, and a cell is counted only when it meets both. This guide shows the formula, the difference between including and excluding the limits, limits stored in cells, and how to build a table of bands.

Why COUNTIF alone can't count between two numbers#

COUNTIF takes a single condition, so it can say "30 or more" or "45 or less", but not both at once. Every example below uses this list of ages in A1:B8:

AB
1EmployeeAge
2Ana24
3Ben37
4Cara45
5Dan29
6Eve52
7Finn31
8Gia40

People often try to squeeze both limits into one criteria, like ">=30<=45" or "30-45". Excel reads those as plain text, finds no cell that matches, and returns 0. You can't put AND inside COUNTIF either. You need two separate conditions.

How to count between two numbers with COUNTIFS#

COUNTIFS takes pairs of a range and a criteria. For a between count, use the same range in both pairs:

Excel formula
=COUNTIFS(B2:B8,">=30",B2:B8,"<=45")
  1. Click an empty cell, such as D2.
  2. Type =COUNTIFS(B2:B8,">=30", for the lower limit.
  3. Type B2:B8,"<=45") for the upper limit.
  4. Press Enter.

The result is 4: Ben (37), Cara (45), Finn (31) and Gia (40). COUNTIFS uses AND logic, so each age must pass both tests. Ana (24) and Dan (29) fail the first; Eve (52) fails the second.

COUNTIFS works in Excel 2007 and every later version. The COUNTIFS function guide lists its arguments, and COUNTIF vs COUNTIFS explains when you need each one.

Including or excluding the limits#

The operators decide whether the limit numbers themselves are counted:

RuleFormulaResult
30 to 45, both included=COUNTIFS(B2:B8,">=30",B2:B8,"<=45")4
Above 30 and below 45=COUNTIFS(B2:B8,">30",B2:B8,"<45")3
30 or more, under 45=COUNTIFS(B2:B8,">=30",B2:B8,"<45")3

Cara is exactly 45, so she drops out as soon as the upper test becomes "<45". Ask yourself what should happen to a value right on the line before you write the formula. For bands that sit next to each other, like 30 to 39 and 40 to 49, a common choice is >= for the lower limit and < for the next band's start. That way no value falls into two bands or into none.

How to use limits stored in cells#

Put the limits in cells so you can change them without editing the formula. With 30 in E1 and 45 in F1:

Excel formula
=COUNTIFS(B2:B8,">="&E1,B2:B8,"<="&F1)

The result is still 4. The & joins each operator to the number in the cell, so Excel sees ">=30" and "<=45". Keep the operator inside quotes and the cell reference outside. Writing ">=E1" makes Excel look for the text "E1" and return 0.

Change F1 to 40 and the count becomes 3 (37, 31 and 40). This is the setup to use in a dashboard or any sheet where someone else picks the range.

The subtraction method with COUNTIF#

You can get the same answer with two plain COUNTIFs: count everything at or above the lower limit, then take away everything above the upper limit:

Excel formula
=COUNTIF(B2:B8,">=30")-COUNTIF(B2:B8,">45")

The first part counts 5 ages (37, 45, 52, 31, 40). The second counts 1 (52). The result, 5 - 1, is 4. Note that the second part uses ">45" so that 45 itself stays in the count. This method is handy in very old files, but COUNTIFS is easier to read, so prefer it.

How to count values in bands#

To see how values spread across ranges, build a small band table and point COUNTIFS at each row. With the band starts in E2:E5 and band ends in F2:F5:

BandStart (E)End (F)Formula in GCount
20s2029=COUNTIFS($B$2:$B$8,">="&E2,$B$2:$B$8,"<="&F2)2
30s3039(filled down)2
40s4049(filled down)2
50s5059(filled down)1

Write the formula once in G2, then fill it down (Windows: Ctrl+D; Mac: ⌘D). The $ signs keep the age range fixed while E2 and F2 move to E3 and F3. The counts add up to 7, one for each employee, which is a quick check that no band overlaps or leaves a gap.

The same idea works for summing instead of counting. The guide to COUNTIFS and SUMIFS with multiple conditions shows how.

Between two dates and other variations#

Dates are numbers in Excel, so the between pattern works on them too. Build each date with DATE:

Excel formula
=COUNTIFS(C2:C8,">="&DATE(2024,3,1),C2:C8,"<="&DATE(2024,3,31))

This counts the dates in March 2024. The guide to COUNTIF with dates covers before, after and whole months.

You can also add a third condition on another column. For example, to count employees aged 30 to 45 in the Sales department, add C2:C8,"Sales" as a third pair. And if you need a label on each row instead of a total, such as "In range", see IF between two numbers.

How to count values outside a range#

To count the values outside a range, add two COUNTIFs, one for each side:

Excel formula
=COUNTIF(B2:B8,"<30")+COUNTIF(B2:B8,">45")

That gives 2 (24 and 29) plus 1 (52), so 3. You can't use COUNTIFS for this, because no age can be both below 30 and above 45 at the same time, so it would return 0. A quick check: inside plus outside should equal the total number of values, and 4 + 3 = 7.

Practise it#

Between counts appear often in job tests because they check that you know COUNTIFS takes the same range twice. Practise COUNTIFS and SUMIFS in a live spreadsheet: you type each formula and the lesson checks it instantly. Or try the exercise on this page and count the employees aged 30 to 45.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

How many employees are aged 30 to 45, including both ages? In D2, use COUNTIFS with two conditions on B2:B8.

fx
ABCDE
1
Employee
Age
2
Ana
24
Aged 30-45
3
Ben
37
4
Cara
45
5
Dan
29
6
Eve
52
7
Finn
31
8
Gia
40
9
10
11

Tip: Use B2:B8 twice: once with ">=30" and once with "<=45".

Practise this in a lesson

LessonCOUNTIFS and SUMIFSCount and sum with several conditions at once, and learn why SUMIFS puts the sum range first.Function guideCOUNTIFSCount rows that meet several conditions with COUNTIFS. Examples for text, number ranges and between-values, plus a live exercise.

Frequently asked questions

How do I count cells between two numbers in Excel?

+

Use COUNTIFS with two conditions on the same range: =COUNTIFS(B2:B8,">=30",B2:B8,"<=45"). It counts the cells from 30 to 45, including both limits.

Can COUNTIF count between two values?

+

Not with one condition. Either use COUNTIFS, or subtract two COUNTIFs: =COUNTIF(B2:B8,">=30")-COUNTIF(B2:B8,">45"). Both return the count from 30 to 45.

How do I count between two numbers stored in cells?

+

Keep each operator in quotes and join the cell with an ampersand: =COUNTIFS(B2:B8,">="&E1,B2:B8,"<="&F1). Change E1 or F1 and the count updates.

Does COUNTIFS between include the end numbers?

+

It depends on the operators. ">=30" and "<=45" include 30 and 45. ">30" and "<45" leave them out. Pick the operators that match your rule.

How do I count dates between two dates?

+

The same pattern works, because dates are numbers: =COUNTIFS(B2:B8,">="&DATE(2024,3,1),B2:B8,"<="&DATE(2024,3,31)) counts the dates in March 2024.

Sources

  • COUNTIFS function - Microsoft Support
  • COUNTIF function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Why COUNTIF alone can't count between two numbers
  2. How to count between two numbers with COUNTIFS
  3. Including or excluding the limits
  4. How to use limits stored in cells
  5. The subtraction method with COUNTIF
  6. How to count values in bands
  7. Between two dates and other variations
  8. How to count values outside a range
  9. Practise it

Keep reading

Logic· 7 min read

IF Between Two Numbers in Excel

To check if a number is between two values in Excel, combine IF with AND: =IF(AND(B2>=1,B2<=5),"Standard","Other"). AND needs both tests to be true: at least the lower limit and at most the upper limit. Use > and < instead to leave out the limits themselves. Excel has no BETWEEN function, so you always write both tests.

Comparisons· 7 min read

COUNTIF vs COUNTIFS: What's the Difference?

COUNTIF counts cells that meet one condition, such as tickets marked Open. COUNTIFS counts rows that meet several conditions at once, such as Open tickets with High priority, and every condition must be true. COUNTIFS with one pair works exactly like COUNTIF, so many people simply use COUNTIFS for everything.

Conditional math· 6 min read

COUNTIF With Dates: Before, After and Between

To count dates in Excel, join an operator to a date built with DATE: =COUNTIF(B2:B8,">="&DATE(2024,3,1)) counts dates on or after 1 March 2024. Use "<" for before. To count between two dates, use COUNTIFS with two conditions: =COUNTIFS(B2:B8,">="&DATE(2024,3,1),B2:B8,"<="&DATE(2024,3,31)). Build dates with DATE rather than typing them as text, which depends on regional settings.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free