RANDBETWEEN returns a random whole number from bottom to top, with both ends possible. =RANDBETWEEN(1, 6) can return 1, 2, 3, 4, 5 or 6, each equally likely. It is the quickest way to simulate dice, draw a sample number or invent test data.
Volatile: the number keeps changing
Like RAND, RANDBETWEEN is volatile. It draws a new number when the workbook recalculates, which includes any edit, pressing F9, and opening the file. To keep a result, copy the cells and use Paste Special > Values. Because the output differs every time, the examples on this page check properties that always hold, such as a result lying between the limits, or fix the limits so there is only one answer.
The arguments
Both arguments are required, and both can be cell references: =RANDBETWEEN(D2, E2). If bottom equals top the answer is that number, so =RANDBETWEEN(5, 5) is always 5. If bottom is larger than top, you get #NUM!. Pass whole numbers for both limits.
Picking a random item from a list
Combine it with INDEX: =INDEX(A2:A9, RANDBETWEEN(1, ROWS(A2:A9))) returns a random name. Using ROWS rather than a fixed 8 keeps the formula right if the list grows.
Random dates and amounts
Dates are numbers, so =RANDBETWEEN(DATE(2025,1,1), DATE(2025,12,31)) returns a random date in 2025 once formatted as a date. For amounts with pence, divide: =RANDBETWEEN(1000, 5000)/100 gives 10.00 to 50.00.
RANDBETWEEN compared with other options
- RAND gives decimals from 0 up to 1. Scaling it, as in
=INT(RAND()*6)+1, does the same job as RANDBETWEEN(1, 6). - RANDARRAY returns many random numbers at once and can return decimals or whole numbers, in Microsoft 365.
- Neither suits security uses such as passwords or lottery draws.
Large ranges of RANDBETWEEN cells slow a workbook down, since every cell recalculates on any change.