Excel guide · 4 min read
How to check if a value is between two numbers in Excel
=IF(AND(B2>=2,B2<=10),"Yes","No"). AND returns TRUE only when the value is at least the lower limit and at most the upper limit, so 2 and 10 count as inside. Use > and < instead to leave the limits out, and put the limits in cells, as in =IF(AND(B2>=$G$1,B2<=$G$2),"Yes","No"), so you can change them without editing the formula.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Parcel | Weight (kg) | Shipped | Min kg | 2 | ||
| 2 | PX-301 | 1.2 | Nov 18, 2026 | Max kg | 10 | ||
| 3 | PX-302 | 2 | Nov 20, 2026 | Promo start | Nov 20, 2026 | ||
| 4 | PX-303 | 6.5 | Nov 24, 2026 | Promo end | Nov 30, 2026 | ||
| 5 | PX-304 | 10 | Nov 27, 2026 | ||||
| 6 | PX-305 | 14 | Nov 30, 2026 16:45 | ||||
| 7 | PX-306 | 7.5 | Dec 1, 2026 | ||||
| 8 | PX-307 | Dec 2, 2026 |
Download this sheet as an Excel practice file (.xlsx)
IF with AND: the standard formula
The sheet is a shipping log. Parcels from 2 to 10 kg go at the standard rate, so each row needs a Yes or No. A value is between two numbers when it passes two tests at once: greater than or equal to the lower limit, and less than or equal to the upper limit. AND checks both, and IF turns the result into a label.
The limits live in G1 and G2 with dollar signs, so the formula can be filled down column D without the references sliding. Change G2 to 12 and every row updates.
Result: Yes
Yes: 6.5 kg is between 2 and 10.
Inclusive or exclusive limits
>= and <= include the limits, so a parcel of exactly 2 kg counts. Switch to > and < when the limits themselves should not count. Row 3 is exactly 2 kg, which shows the difference: inclusive says Yes, exclusive says No.
When bands sit back to back (2-10 kg, then 10-20 kg), make one end inclusive and the other exclusive, such as >= the lower limit and < the upper. Otherwise a 10 kg parcel lands in both bands.
Result: No
No: 2 is not greater than 2. With >= and <= the same row returns Yes.
Why =IF(2<=B4<=10, ...) gives the wrong answer
It reads like maths, but Excel works left to right. 2<=B4 becomes TRUE, then Excel compares TRUE<=10. In Excel comparisons, TRUE and FALSE rank above every number, so that is FALSE, and the formula says No for every parcel. There is no error to warn you. Always split the test into two parts inside AND.
Result: No
No, even though 6.5 kg is between 2 and 10.
Between two dates (and the time-of-day trap)
Dates are numbers in Excel, so the same AND test works. Keep the start and end dates in cells (G3 and G4 here), or build them with DATE(2026,11,20). Do not type a date in quotes, as in C6<="11/30/2026": that is text, not a date, and because Excel ranks text above every number, the comparison is TRUE for any date.
Row 6 shipped on November 30, the last promo day, but at 16:45. A date with a time is bigger than the plain date, so C6<=$G$4 is FALSE and =IF(AND(C6>=$G$3,C6<=$G$4),"Promo","Regular") says Regular. Test against the start of the next day instead: less than the end date plus 1.
Result: Promo
Promo: the 16:45 shipment on the last day counts.
The MEDIAN trick: limits in either order
If people might type the limits the wrong way round (10 in G1, 2 in G2), the AND formula silently says No to everything. MEDIAN of three numbers returns the middle one, so a value is between the limits exactly when it is the median of itself and the two limits, whichever order they are in.
It is always inclusive, and MEDIAN skips empty and text cells. If a limit cell is blank, MEDIAN works on two numbers and the answer is quietly wrong, so only use it when both limits are filled. The plain alternative is =IF(AND(B4>=MIN($G$1,$G$2),B4<=MAX($G$1,$G$2)),"Yes","No").
Result: Yes
Yes: 6.5 is the middle of 6.5, 2 and 10. It still says Yes if the limits are swapped.
Blank cells and numbers stored as text
Row 8 has no weight. An empty cell counts as 0, so with limits of 2 and 10 it says No, but with a lower limit of 0 it would say Yes. Skip empty rows first with =IF(B8="","",IF(AND(B8>=$G$1,B8<=$G$2),"Yes","No")).
Row 7 holds 7.5 imported as text. Excel ranks text above every number in comparisons, so B7>=2 is TRUE but B7<=10 is FALSE, and a 7.5 kg parcel gets No. Convert the column to real numbers (the numbers stored as text guide shows how) or wrap the cell in VALUE().
Result: No
No, because 7.5 is text. =IF(AND(VALUE(B7)>=$G$1,VALUE(B7)<=$G$2),"Yes","No") returns Yes.
Labels for several bands, and the whole column at once
For more than two outcomes, test the bands in order with IFS (Excel 2019 and later) so each test only needs its upper limit: the first true test wins. With many bands, a small lookup table with each band's lower limit and VLOOKUP(B2,table,2,TRUE) is easier to maintain.
In Excel 365 you can test the whole column in one spilled formula, but not with AND, because AND collapses every row into a single TRUE or FALSE. Multiply the tests instead: =IF((B2:B8>=G1)*(B2:B8<=G2),"Yes","No"). To count the rows in range rather than label them, use COUNTIFS with two conditions.
Result: Oversize
Oversize: 14 kg is above every band. 1.2 kg would be Small, 6.5 kg Standard.
Common mistakes
Writing 2<=B2<=10
Excel compares left to right and the result is always FALSE. Use AND(B2>=2,B2<=10).
Forgetting the dollar signs on limit cells
Without $G$1 and $G$2 the limit references move down as you fill, and lower rows test against empty cells.
End dates that miss the last day
Dates with times are larger than the plain date. Test < end date + 1 instead of <= end date.
Overlapping bands
If one band ends at 10 and the next starts at 10, a value of 10 matches both. Make one side exclusive.
FAQ
How do I write IF between two numbers in Excel?
=IF(AND(B2>=2,B2<=10),"Yes","No"). Replace 2 and 10 with your limits or with locked cell references such as $G$1 and $G$2.
How do I check if a date is between two dates in Excel?
=IF(AND(C2>=G3,C2<=G4),"Yes","No") with the start date in G3 and the end date in G4. If the dates carry times, use C2<G4+1 for the end test.
Is there a BETWEEN function in Excel?
No. Combine two comparisons with AND, or use the MEDIAN trick, =B2=MEDIAN(B2,low,high), which returns TRUE when the value is between the limits, inclusive.
How do I return a value instead of Yes or No?
Put any value or formula in the IF branches, for example =IF(AND(B2>=2,B2<=10),4.95,9.95) for a shipping fee. Keep fees in cells if they change.
Functions used
IFPicks a result from a testANDTrue if all tests are trueMEDIANMiddle valueMINSmallest numberMAXLargest numberIFSFirst true test winsVALUEText to numberDATEBuilds a dateCOUNTIFSCounts with several conditionsVLOOKUPVertical lookup
Related guides
- How to use IF with AND and OR in Excel
- COUNTIFS between two numbers in Excel
- Excel IF statement with multiple conditions
- IF a date is before or after another date in Excel
- Pass/fail formula in Excel
- Excel formulas cheat sheet: the 25 everyone should know
- Tiered commission in Excel: sliding-scale formulas that match your plan
Updated