ReferenceFunctionsRandom Functions
RANDBETWEEN
RANDBETWEEN: Returns a random integer between two inclusive bounds.
Summary
RANDBETWEEN evaluates both bounds, then samples an integer in [low, high].
Remarks
- Bounds are coerced to numbers and truncated to integers.
- If
high < low, the function returns#NUM!. - The function is volatile and may return a different integer each recalculation.
Examples
Value always falls inside the requested interval
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
true
Equal bounds produce a fixed value
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
7
Upper bound below lower bound is invalid
Grid
| Cell | Value | |
|---|---|---|
| No inputs on Sheet1. | ||
Formula
=
Result
Not evaluated yet.
Expected
#NUM!
Related functions
FAQ
Are both bounds included in RANDBETWEEN?
Yes. RANDBETWEEN samples an integer in the closed interval [low, high].
What happens with decimal bounds like RANDBETWEEN(1.9, 4.2)?
Bounds are truncated to integers before sampling, so this behaves like RANDBETWEEN(1, 4).
Is RANDBETWEEN deterministic?
It is volatile, so results can change on recalculation, though a single evaluation context uses seeded randomness for reproducible execution.
Runtime metadata
Category
Random
Signature
RANDBETWEEN(arg1: Number, arg2: Number)Arity
min 2, max 2
Arguments
arg1Number · Scalar · coercion NumberLenientText
arg2Number · Scalar · coercion NumberLenientText
Caps
VOLATILE
Source