How to check if a number is between two values in Excel
Formula (Excel and Google Sheets)
=IF(AND(B2>=$F$1,B2<=$F$2),"In range","Out of range")Use AND with both limits: =IF(AND(value>=low,value<=high),"In range","Out of range").
- Result on the example
- one result per row in
C2, filled down toC7 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in C2, filled down to C7. Change any input and the result updates, or edit the formula to experiment.
How it works
"Between" is two conditions: at least the low limit and at most the high limit. AND returns TRUE only when both hold. Using >= and <= includes the limits; use > and < to exclude them.
=IF(AND(B2>=$F$1,B2<=$F$2),"In range","Out of range")Result"In range"
B219.5The value in B2.
$F$118The value in F1.
B2>=$F$1TRUEThe >= operator tests at least.
$F$224The value in F2.
B2<=$F$2TRUEThe <= operator tests at most.
AND(B2>=$F$1,B2<=$F$2)TRUEAND: TRUE if every argument is true.- logical1
B2>=$F$1TRUE - logical2
B2<=$F$2TRUE
- logical1
IF(AND(B2>=$F$1,B2<=$F$2),"In range","Out of range")"In range"IF: Returns one value if a test is true, another if false.- logical_test
AND(B2>=$F$1,B2<=$F$2)TRUE - value_if_true
"In range" - value_if_false
"Out of range"not used
- logical_test
In Google Sheets
The same formula works in Google Sheets: =IF(AND(B2>=$F$1,B2<=$F$2),"In range","Out of range"). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =IF(MEDIAN($F$1,B2,$F$2)=B2,"In range","Out of range") | In range, Out of range, In range… | A compact trick: a value is between two limits exactly when it is their median. It also works when the limits are entered in either order. |
| =IF(ABS(B2-($F$1+$F$2)/2)<=($F$2-$F$1)/2,"In range","Out of range") | In range, Out of range, In range… | Distance from the midpoint, handy when the range is a target plus or minus a tolerance. |
Common mistakes
=IF(18<=B2<=24,…)doesn't work as in maths: Excel compares 18<=B2 first, gets TRUE or FALSE, then compares that with 24.- Lock the limits with $ before filling down, or the references slide down to empty cells.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Check if a number is between two values
C2, show "In range" when the temperature is between the low and high limits in F1 and F2 (limits included), otherwise "Out of range". Fill down to C7.Questions
How do I count values between two numbers?
Use COUNTIFS with two conditions on the same range, for example =COUNTIFS(B2:B7,">="&F1,B2:B7,"<="&F2).
How do I highlight values in a range?
Use the same AND test as a conditional formatting rule: =AND($B2>=$F$1,$B2<=$F$2).
Checked by running on 2026-10-29: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.