Use the RANDBETWEEN function to generate random values in a specified range
To generate randomized values in a specified range, such as from 1 to 49, use the RANDBETWEEN function. This function returns a random number in the range you specify, returning a new random number every time the worksheet is calculated. If this function is not available and returns the #NAME? error, install and load the
Analysis ToolPak add-in. Here is the syntax that is used:
RANDBETWEEN(bottom, top)
bottom: The lowest integer in the range.
top: The highest integer in the range.
To create random values from 1 to 49:
- Select cells A2:D10 and type the following formula: =RANDBETWEEN(1,49).
- Press Ctrl+Enter.
- Press Ctrl+C to copy the filled cells.
- From the Edit menu, select Paste Special.
- In the Paste Special dialog box, select the Values option button to paste only the values, and click OK.
Random values are sometimes used for mathematic studies or for programming a lottery.
This tip is compatible with Excel 97, 2000, 2003 and 2007.
