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. Logic
  3. IF Between Two Numbers in Excel

IF Between Two Numbers in Excel

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

The short answer

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.

Key takeaways

  • The pattern is =IF(AND(value>=low, value<=high), "Yes", "No").
  • = and <= include the limits; > and < exclude them.

  • Never write 1<=B2<=5; it returns a wrong answer without any error.
  • Put the limits in cells and use MIN and MAX if you don't know which limit is bigger.
  • For several bands, use nested IF, IFS or an approximate-match lookup.
On this page+
  1. How to check if a number is between two values
  2. Inclusive or exclusive: >= or >?
  3. Why 1<=B2<=5 doesn't work
  4. How to use limits stored in cells
  5. The MEDIAN shortcut
  6. How to check if a number is outside a range
  7. How to sort values into several bands
  8. How to count or sum values between two numbers
  9. Practise it

To check if a value falls between two numbers in Excel, use IF with AND: =IF(AND(B2>=1,B2<=5),"Standard","Other"). Excel has no BETWEEN function, so you write two tests, one for each limit, and AND makes sure both are true. This guide covers inclusive and exclusive limits, limits stored in cells, the MEDIAN shortcut, and how to sort values into several bands.

How to check if a number is between two values#

Write one test for the lower limit and one for the upper limit, and put both inside AND.

Excel formula
=IF(AND(B2>=1,B2<=5),"Standard","Other")

The examples use this parcel list in A1:B7. Parcels from 1 to 5 kg ship as Standard:

AB
1ParcelWeight (kg)
2P10.8
3P22.5
4P35
5P47.2
6P512
7P64.9

Fill the formula from C2 down to C7 (Windows: Ctrl+D; Mac: ⌘D). P2, P3 and P6 show Standard. P1 is too light, and P4 and P5 are too heavy, so they show Other.

AND returns TRUE only when every test inside it is true. The guide to IF with AND explains how it works in more detail, and the AND function guide is a quick reference.

Inclusive or exclusive: >= or >?#

>= and <= include the limits. > and < leave them out. P3 weighs exactly 5 kg, so the choice decides its result.

FormulaIncludes 1 and 5?P3 (5 kg)
=IF(AND(B4>=1,B4<=5),"Standard","Other")Yes, bothStandard
=IF(AND(B4>1,B4<5),"Standard","Other")NoOther
=IF(AND(B4>=1,B4<5),"Standard","Other")1 yes, 5 noOther

Words like "from 1 to 5", "at least" and "up to" mean the limit is included. "Over", "under" and "more than" mean it isn't. When bands meet, such as 0-5 and 5-10, include each limit in only one band so no value falls into both or neither.

Why 1<=B2<=5 doesn't work#

The maths-style chain looks right but gives wrong answers without any error. Excel reads =1<=B2<=5 from left to right: first it works out 1<=B2, which is TRUE or FALSE. Then it compares that TRUE or FALSE with 5.

In Excel, a logical value is always treated as greater than any number. So TRUE<=5 is FALSE, and FALSE<=5 is FALSE too. The formula says every parcel is outside the range, even P2. Always write two separate comparisons inside AND.

How to use limits stored in cells#

Put the lower limit in E1 and the upper limit in F1, then lock them with dollar signs:

Excel formula
=IF(AND(B2>=$E$1,B2<=$F$1),"Standard","Other")

Now you can change the band without touching the formula. Press F4 on Windows (⌘T on Mac) to add the $ signs while the cursor is in the reference.

If you're not sure which limit is bigger, for example when two people type them, let MIN and MAX sort it out:

Excel formula
=IF(AND(B2>=MIN($E$1,$F$1),B2<=MAX($E$1,$F$1)),"Inside","Outside")

This works whether E1 holds 1 and F1 holds 5, or the other way round.

Between two dates or times#

Dates and times are numbers in Excel, so the same pattern works. Build each limit with DATE rather than typing a date in quotes:

Excel formula
=IF(AND(B2>=DATE(2026,1,1),B2<=DATE(2026,3,31)),"Q1","")

This labels every date in the first quarter of 2026. A date typed as text, such as "31/03/2026", is compared as text, and the test quietly fails. If B2 also holds a time of day, an order placed at 3 pm on 31 March is slightly larger than DATE(2026,3,31), which means midnight. Use B2<DATE(2026,4,1) as the upper test to include the whole last day.

The MEDIAN shortcut#

A number is between two limits, inclusive, exactly when it's the middle value of the three. MEDIAN finds the middle value:

Excel formula
=IF(B2=MEDIAN(B2,1,5),"Standard","Other")

For P2, MEDIAN(2.5, 1, 5) is 2.5, which equals B2, so the result is Standard. For P4, MEDIAN(7.2, 1, 5) is 5, which doesn't equal 7.2, so it's Other. It's short and doesn't care about the order of the limits, but AND is easier for others to read. Use MEDIAN only for inclusive checks.

How to check if a number is outside a range#

Use OR with the opposite tests: below the lower limit or above the upper limit.

Excel formula
=IF(OR(B2<1,B2>5),"Outside","Inside")

P1, P4 and P5 show Outside. This is the mirror image of the AND version: notice that >= becomes < and <= becomes >. The guide to IF with OR covers OR in detail.

How to sort values into several bands#

When there are more than two outcomes, nest IFs from the smallest band up. Each test only needs the upper limit, because the earlier tests have already caught the smaller values.

Excel formula
=IF(B2<1,"Small",IF(B2<=5,"Standard",IF(B2<=10,"Large","Freight")))

P1 is Small, P2, P3 and P6 are Standard, P4 is Large and P5 is Freight. In Excel 2019 and later, IFS reads more easily:

Excel formula
=IFS(B2<1,"Small",B2<=5,"Standard",B2<=10,"Large",TRUE,"Freight")

For many bands, such as tax brackets or grade boundaries, a lookup table with an approximate match is easier to maintain than a long formula. For partial text checks instead of numbers, see IF with text.

How to count or sum values between two numbers#

IF checks one row at a time. To count all the values in a range, use COUNTIFS with two conditions on the same column:

Excel formula
=COUNTIFS(B2:B7,">=1",B2:B7,"<=5")

The result is 3. SUMIFS works the same way for totals. The guide to COUNTIF between two numbers explains the quotes and operators, and the IF function explained simply covers the basics of IF. The IF function guide has the full syntax.

Practise it#

Between checks are a staple of Excel tests because they combine IF, AND and careful operators. Practise AND, OR and NOT in a live spreadsheet: you type the formula and it checks it instantly. Then practise the IF function, and try the intermediate Excel test when you're ready.

Try it yourself

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

Parcels from 1 to 5 kg (including both limits) ship as Standard. Click C4 and write an IF with AND that shows Standard or Other for parcel P3.

fx
ABCD
1
Parcel
Weight (kg)
Service
2
P1
0.8
3
P2
2.5
4
P3
5
5
P4
7.2
6
P5
12
7
P6
4.9
8
9
10

Tip: Two tests inside AND: B4>=1 and B4<=5.

Practise this in a lesson

LessonAND, OR and NOTCheck several conditions at once with AND and OR, flip a result with NOT, and combine them inside IF.LessonThe IF functionMake a cell show one result or another depending on a condition, like Pass/Fail or Over/Under budget.Function guideIFLearn Excel's IF function with practical examples: flag budgets, label rows and return blanks. Avoid the classic mistakes and practice live.Function guideANDCheck that every condition is true with Excel's AND. Use it inside IF for bonuses, ranges and eligibility rules, then try a live exercise.

Frequently asked questions

How do I write an IF between two numbers formula in Excel?

+

Use IF with AND: =IF(AND(A2>=10,A2<=20),"Yes","No"). The cell shows Yes when A2 is from 10 to 20, including 10 and 20.

Is there a BETWEEN function in Excel?

+

No. You build the check yourself with AND and two comparisons, or use the MEDIAN trick: =IF(A2=MEDIAN(A2,10,20),"Yes","No").

How do I exclude the limits in a between check?

+

Use > and < instead of >= and <=: =IF(AND(A2>10,A2<20),"Yes","No"). Now 10 and 20 return No.

How do I check if a number is outside a range?

+

Use OR with the opposite tests: =IF(OR(A2<10,A2>20),"Outside","Inside"). Or wrap the between test in NOT.

How do I count values between two numbers?

+

Use COUNTIFS with two conditions on the same range: =COUNTIFS(B2:B7,">=1",B2:B7,"<=5").

Sources

  • IF function - Microsoft Support
  • AND function - Microsoft Support
  • IFS 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. How to check if a number is between two values
  2. Inclusive or exclusive: >= or >?
  3. Why 1<=B2<=5 doesn't work
  4. How to use limits stored in cells
  5. The MEDIAN shortcut
  6. How to check if a number is outside a range
  7. How to sort values into several bands
  8. How to count or sum values between two numbers
  9. Practise it

Keep reading

Logic· 6 min read

IF with AND in Excel: Check Two Conditions at Once

To check two conditions at once, put AND inside IF: =IF(AND(B2>=80000,C2>=95%),"Bonus","No bonus"). AND returns TRUE only when every condition inside it is true, and IF turns that into the result you choose. You can list up to 255 conditions in AND, separated by commas. If any one is false, IF returns the false result.

Logic· 6 min read

IF with OR in Excel: Pass When Any Condition Is Met

To pass when any one of several conditions is true, put OR inside IF: =IF(OR(B2="VIP",C2>=500),"Free shipping", "Standard"). OR returns TRUE if at least one condition is true, and FALSE only when all of them are false. IF then shows the result you choose. Each condition must be written in full, even when it tests the same cell.

Conditional math· 6 min read

COUNTIF Between Two Numbers in Excel

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.

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