RANDBETWEEN Function
The RANDBETWEEN function returns a random integer between two numbers you specify. This function comes in handy when you want to generate sample data between two numbers. For example, if you want to generate some sample data between 1 and 100 in several cells, you could use RANDBETWEEN to generate a random number in one cell and copy the formula over the required range.
Syntax
RANDBETWEEN(bottom, top)
Arguments
Argument
Description
Bottom
Required. The smallest integer to be returned.
Top
Required. The largest integer to be returned.
Note : The random values are regenerated each time the worksheet is recalculated. Hence, if you generate random values that you don’t want to change each time the worksheet is recalculated, you need to copy only the values to another range without the formulas.
Example
In this example, we will use the RANDBETWEEN function to generate sample data for student scores between 0 and 100.
Tip : To keep only the generated values without the formula, generate the sample data in a different part of your worksheet and then copy and paste only the values into your target range. For example, if you wanted random values in cells B2:B10, generate the values using RANDBETWEEN in cells F2:F10 and then copy and paste only the values in B2:B10, then delete the values in F2:F10.