Spreadsheet Practice

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 to C7
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"

  1. B219.5

    The value in B2.

  2. $F$118

    The value in F1.

  3. B2>=$F$1TRUE

    The >= operator tests at least.

  4. $F$224

    The value in F2.

  5. B2<=$F$2TRUE

    The <= operator tests at most.

  6. AND(B2>=$F$1,B2<=$F$2)TRUE

    AND: TRUE if every argument is true.

    • logical1B2>=$F$1TRUE
    • logical2B2<=$F$2TRUE
  7. 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_testAND(B2>=$F$1,B2<=$F$2)TRUE
    • value_if_true"In range"
    • value_if_false"Out of range"not used

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.

FormulaResultWhen 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

In 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.