You often need to return a random number between two numbers for sampling purpose or assigning a random value to a data set. Excel RANDBETWEEN function has a built-in function to perform this task.
Random number between two numbers
Excel RANDBETWEEN function returns a random number between two numbers or between given bottom and top range. It is categorized as Math/Trig Function and it returns new random number each time worksheet recalculates.
The syntax of Excel RANDBETWEEN function is:
There are two required arguments.
Bottom: It is the smallest integer value specified that the function will return.
Top: It is the largest integer value specified that the function will return.
Excel RANDBETWEEN function returns a random number between two numbers specified in function as the bottom and top numeric values.
For example, you want to generate a random number between two numbers i.e. 1 and 50 in a range of cells A2: A21. You need to insert the formula in cell A2 and drag or copy and paste this formula to cell A21. Excel will return a random number between two numbers specified in the formula, such as;
Figure 1. Random_Between-two-numbers
Please note that RANDBETWEEN function returns a new random number between two numbers whenever you edit any cell in the range containing formulas or you open the worksheet again. If you want to restrict with an initially generated random number between two numbers then you need to replace the formulas with values in the applied range. Simply, select the range of cells A2:A21, copy the formulas > paste special > and click on values and save.