The RANDBETWEEN function returns a random integer between two given values drawn from a discrete uniform distribution.
RANDBETWEEN(
bottom,
top
)
- bottom: Lower value to be returned by the function.
- top: Higher value to be returned by the function.
The RANDBETWEEN function returns an integer.
The returned number will belong to the closed range [bottom, top]. That is, it can also take both values.
bottom must be less than or equal to top. If not, the function returns an error. Both bottom and top can be real numbers (the result will still be an integer between both values). If there are no integers between bottom and top, the function returns an error:
The bottom and top values can be less than zero (as long as the aforementioned conditions are respected):
The following example generates a random integer between the numbers 4.5 and 7.81 (that is, a random number 5, 6, or 7 is generated):