RANDBETWEEN function
The RANDBETWEEN function in Excel generates a random integer between two specified numbers (inclusive). It’s a simple and effective way to create random whole numbers within a defined range.
Syntax
=RANDBETWEEN(bottom, top)
Parameters
- bottom: The smallest integer in the range.
- top: The largest integer in the range.
Key Features
- Inclusive Range: Both the
bottomandtopvalues are included in the range of possible results. - Dynamic Updates: The function recalculates whenever the worksheet recalculates (e.g., when pressing
F9or entering new data).
Examples
- Generate a random integer between 1 and 100:
=RANDBETWEEN(1, 100) - Generate a random integer between -10 and 10:
=RANDBETWEEN(-10, 10) - Generate a random number to simulate a dice roll (1 to 6):
=RANDBETWEEN(1, 6) - Generate a random integer between 100 and 200 for a list of cells: Enter
=RANDBETWEEN(100, 200)in one cell, then drag to fill multiple cells.
Tips
- Prevent Recalculation: To prevent the random number from changing every time the worksheet recalculates, copy the cell and paste it as a value (
Ctrl + Alt + V→ “Values”). - For decimals, use
RANDorRANDARRAYfunctions combined with formulas to adjust the range. - Use
RANDBETWEENin combination with other functions for advanced scenarios (e.g., simulating random selections).
Comparison with Other Functions
RAND: Generates decimals between 0 and 1.RANDARRAY: Can generate an array of random numbers with more control (e.g., decimals, integers, and range customization).