Random Numbers in Excel: Simple Formulas
In this article
To generate random numbers in Excel with simple formulas, use =RAND() for a decimal between 0 and 1, or =RANDBETWEEN(bottom, top) for a whole number within a range you specify. These two built-in functions cover most random-number needs without any add-ins or complex programming.
How RAND and RANDBETWEEN Work
RAND() takes no arguments and returns a decimal number greater than or equal to 0 and less than 1. Every time the worksheet recalculates, it produces a new value. RANDBETWEEN(bottom, top) returns an integer between the two numbers you provide, inclusive. For example, =RANDBETWEEN(1, 10) gives a whole number from 1 to 10.
Both functions are volatile, meaning they recalculate whenever Excel performs any calculation—such as editing a cell, opening the file, or pressing F9. This behavior is useful for simulations but can be annoying if you want a static list of random numbers.
Making Random Numbers in a Range
To get a decimal between two specific values, combine RAND with arithmetic. The formula =RAND() * (max - min) + min produces a decimal in the range from min to max. For instance, =RAND() * (100 - 50) + 50 gives a number between 50 and 100. If you need a random percentage between 0% and 5%, use =RAND() * 0.05 and format the cell as a percentage.
For a random integer with a step other than 1, multiply the result of RANDBETWEEN. To get even numbers from 2 to 20, use =RANDBETWEEN(1, 10) * 2. To get multiples of 5 from 5 to 50, use =RANDBETWEEN(1, 10) * 5.
Generating a List of Random Numbers
To fill a column with random numbers, enter the formula in the first cell and drag the fill handle down. Each cell gets its own independent random value. If you need a large list, double-click the fill handle after selecting the first cell—Excel copies the formula down as far as the adjacent column has data.
If you want the list to stay fixed and not change every time you edit something, copy the cells and paste them back as values using Paste Special (Ctrl+Alt+V, then V). This replaces the formulas with the numbers they produced, freezing them permanently.
Common Problems and Misconceptions
- Numbers change unexpectedly: This is normal because RAND and RANDBETWEEN are volatile. To stop it, convert to values as described above.
- RANDBETWEEN returns the same number repeatedly: This can happen if you copy a single formula without adjusting it—each cell should have its own formula. Also, check that the bottom value is less than the top.
- Need to avoid duplicates: RAND and RANDBETWEEN can produce duplicates, especially with small ranges. For a unique list, use the RAND function to assign a random key to each item, then sort by that key.
- RAND() gives 0 or 1: RAND never returns 1, but it can return 0. If you need numbers strictly greater than 0, use
=RAND() * 0.9999 + 0.0001or similar.
Alternatives for More Control
Excel offers other random-related functions. RANDARRAY (available in Excel 365 and Excel 2021) creates an array of random numbers in one step. For example, =RANDARRAY(5, 3, 1, 100, TRUE) returns a 5-row by 3-column array of integers from 1 to 100. The TRUE argument specifies integers; FALSE gives decimals.
For random dates, combine RANDBETWEEN with date serial numbers. =RANDBETWEEN(DATE(2024,1,1), DATE(2024,12,31)) returns a random date in 2024. Format the cell as a date to see it properly.
If you need to generate random text or pick a random item from a list, use =INDEX(list_range, RANDBETWEEN(1, COUNTA(list_range))). This selects a random row from the named range.
When to Use RAND vs RANDBETWEEN
Choose RAND when you need a continuous decimal value, such as a random probability, a random time, or a random coordinate. Use RANDBETWEEN when you need whole numbers like dice rolls, lottery picks, or random IDs. For most everyday tasks, RANDBETWEEN is more intuitive because it directly gives you the range you want.
If you need a random sample from a dataset, add a column with =RAND(), sort by that column, and take the top N rows. The decimals avoid ties that would occur with integers.
Frequently Asked Questions
How do I stop random numbers from changing in Excel?
Copy the cells containing the formulas and paste them back as values. Select the range, press Ctrl+C, then right-click and choose Paste Special > Values. The numbers become static text and no longer change.
Can I generate random numbers without duplicates?
Yes. One method is to create a list of numbers from 1 to N, then add a column of RAND() values, sort by that column, and delete the helper column. Another is to use the RANDARRAY function with the SORTBY function, but the simplest is the sort method.
Does Excel have a random number generator for normal distributions?
Not directly. You can approximate a normal distribution using the Box-Muller transform: =SQRT(-2*LN(RAND()))*COS(2*PI()*RAND()). This gives a standard normal value with mean 0 and standard deviation 1. Multiply by your desired standard deviation and add the mean to shift it.
Why does RANDBETWEEN sometimes return the same number?
It's random, so duplicates are possible, especially when the range is small. If you need unique numbers, use a different approach like the sort method or check for duplicates manually. With a range of 1 to 10, the chance of a duplicate in a list of 10 is quite high.
Is there a way to generate random numbers in Excel without a formula?
Yes. You can use the Data Analysis Toolpak's Random Number Generation feature, which fills a range with numbers from various distributions without leaving formulas. This is useful when you want a one-time set of numbers that won't change.
What is the difference between RAND and RANDARRAY?
RAND returns a single decimal between 0 and 1. RANDARRAY returns an array of numbers with specified rows and columns, and you can set the min, max, and whether to use integers. RANDARRAY is more powerful but only available in newer versions of Excel.