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.
Syntax =xl.between(value, low, high)
=LAMBDA(value, low, high,
LET(
above, value >= low,
below, value <= high,
AND(above, below)
)
)Arguments
| Name | Required | What to pass |
|---|---|---|
| value | Required | The number or date to test. |
| low | Required | The lower end, included. |
| high | Required | The upper end, included. |
Examples
A score inside a band
=xl.between(5, 1, 10)Result TRUE
| A | B | |
|---|---|---|
| 1 | Value | 5 |
| 2 | Low | 1 |
| 3 | High | 10 |
| 4 | Inside | TRUE |
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.