The Excel Randbetween function generates a random integer between two given integers.
The syntax of the function is :
where the bottom and top arguments are integers representing the lower and upper limits for the generated random number.
These arguments can be supplied to the function as either simple numbers, references to cells containing numbers, or as values returned from other functions or formulas.
The spreadsheet below shows two examples of the Excel Randbetween function used to generate random numbers.
A | ||
---|---|---|
1 | =RANDBETWEEN( 1, 10 ) | - returns a random number between 1 and 10 |
2 | =RANDBETWEEN( -2, 2 ) | - returns a random number between -2 and 2 |
Note that the above formulas will return a different random number every time the spreadsheet recalculates. To force a recalculation at any time, press the F9 key.
Further information and examples of the Excel Randbetween Function are provided on the Microsoft Office website.
If you get an error from the Excel Randbetween function, this is likely to be one of the following :
#VALUE! | - | Occurs if either of the supplied arguments are not recognised as numeric values. |
#NUM! | - | Occurs if the supplied 'bottom' argument is greater than the supplied 'top' argument. |