← All how-to recipes

How to test if a value is between two numbers

✓ Verified in LibreOffice 25.8.7.3

An in-range check — because 10<=A2<=20 doesn't work the way you'd hope.

The formula

AppFormulaNotes
Excel=IF(AND(A2>=10,A2<=20),"In range","Out")There's no BETWEEN operator; AND of two comparisons is the idiom.
Google Sheets=IF(AND(A2>=10,A2<=20),"In range","Out")Identical.
LibreOffice Calc=IF(AND(A2>=10,A2<=20),"In range","Out")Identical.

How it works

The chained form 10<=A2<=20 doesn't error — worse, it evaluates left-to-right into TRUE<=20, which is always TRUE, so everything passes the test. AND(A2>=10,A2<=20) is the correct spelling: 15 clears both bounds. An arithmetic alternative some prefer: =MEDIAN(10,A2,20)=A2 is TRUE exactly when A2 is within [10,20] — and MEDIAN(10,A2,20) by itself doubles as a clamp.

Verified, not just documented

We ran =IF(AND(A2>=10,A2<=20),"In range","Out") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned In range — exactly the expected result. Every formula here is confirmed by actually executing it.