top of page

You are learning Functions and Formulas in MS Excel

How do I generate random numbers within a specific range?

In Excel, you can generate random numbers within a specific range using the RANDBETWEEN function. Here's how:

1. Select the cell where you want the random number to appear.
2. Type the formula: `=RANDBETWEEN(bottom, top)`.
3. Replace "bottom" and "top" with the actual numbers representing the lower and upper limits of your desired range (inclusive).
- Important: The bottom number must be less than or equal to the top number.

Example:

- If you want a random number between 10 and 20 (inclusive), you would enter:
`=RANDBETWEEN(10, 20)`

Press Enter. Excel will generate a random integer between 10 and 20 and display it in the cell.

Additional Notes:

* RANDBETWEEN is volatile: This means whenever you make any changes to the worksheet (even unrelated to the formula), the random number will recalculate and generate a new one.
* Copy and Paste Special: If you want to fix the generated random number and prevent it from changing, copy the cell containing the formula and then paste it using "Paste Special" -> "Values." This will paste only the static value and not the formula itself.
* Multiple Random Numbers: You can drag the formula down to a range of cells to generate multiple random numbers within the same specified range.

For more advanced random number generation, Excel also offers the RAND function (which generates random decimals between 0 and 1) and the RANDARRAY function (available in Excel 365 for generating arrays of random numbers with more customization options).

bottom of page