LAMBDA · Validation

Between LAMBDA

xl.between returns TRUE when a value is between two ends, including the ends. 5 is between 1 and 10. 10 is between 1 and 10. 11 is not.

Microsoft 365, Excel 2024, and Excel for the web. Excel 2021 does not have LAMBDA.

Syntax =xl.between(value, low, high)

xl.between
=LAMBDA(value, low, high,
  LET(
    above, value >= low,
    below, value <= high,
    AND(above, below)
  )
)

Arguments

NameRequiredWhat to pass
valueRequiredThe number or date to test.
lowRequiredThe lower end, included.
highRequiredThe upper end, included.

Examples

A score inside a band

=xl.between(5, 1, 10)

Result TRUE

=AND(B1>=B2,B1<=B3)B4
Band
AB
1Value5
2Low1
3High10
4InsideTRUE
A picture of the sheet, not a live calculator.

xl.between is the inclusive range test. 5 is between 1 and 10. So is 10. 11 is not. Dates work the same way because they are numbers. A due date on the last day of the window is inside, not past it.

The ends are included on purpose. A discount “from $100 to $500” should catch the $100 order and the $500 order.

Add it to the workbook

Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.between, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.between(...).

The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.

How it works

Two comparisons are named and combined with AND. There is no ABS and no swap. If low is greater than high, nothing passes.

Limits

Text is compared alphabetically if you pass text, which is rarely the band you meant. Pass numbers or dates. A blank value is treated as 0 in a numeric comparison.