The RANDBETWEEN function in Google Sheets is a powerful tool for generating random integers within a specified range. It enables users to add an element of randomness to their spreadsheets, which can be particularly useful for simulations, games, and random sampling applications.
Syntax
RANDBETWEEN(bottom, top)
- bottom: The smallest integer that can be returned.
- top: The largest integer that can be returned.
Example #1
RANDBETWEEN(1, 10)
This function call generates a random integer between 1 and 10, inclusive. For instance, the output might be 7.
Example #2
RANDBETWEEN(-5, 5)
This call generates a random integer between -5 and 5, inclusive. A possible output could be -2.
Example #3
RANDBETWEEN(100, 200)
This function call produces a random integer between 100 and 200, inclusive. For example, it might yield 150.
Error handling
- NUM!: Occurs when ‘bottom’ is greater than ‘top’. Ensure the first argument is smaller or equal to the second.
- VALUE!: Raised when non-numeric arguments are supplied. Check that both parameters are valid numbers.