To generate 20 random numbers in Excel, use the =RANDBETWEEN(bottom, top) function for whole numbers or the =RAND() function for decimals, then click and drag the fill handle down across 20 cells. This process allows you to quickly create a randomized dataset for sampling, lottery draws, or testing data without manually entering every digit.
What You'll Need
- A computer with Microsoft Excel installed (all versions) or a web browser using Excel for the Web.
- A basic understanding of how to select cells and enter formulas.
- A defined range for your numbers (e.g., knowing if you need numbers between 1 and 100).
Step-by-Step
- Open your Excel Workbook: Launch Microsoft Excel and open a new or existing spreadsheet. Click on the cell where you want your list of random numbers to begin (for example, cell A1).
- Choose Your Randomization Method: Depending on the type of numbers you need, you will use a different formula.
- For Whole Numbers (Integers): Use the
RANDBETWEENfunction. This is the most common method for things like raffle tickets or ID numbers. Type=RANDBETWEEN(1, 100)if you want numbers between 1 and 100. You can change these numbers to any minimum and maximum you prefer. - For Decimals (0 to 1): Use the
RANDfunction. Type=RAND(). This generates a random decimal number greater than or equal to 0 and less than 1. - For Dynamic Arrays (Office 365): If you have a modern version of Excel, you can use
=RANDARRAY(20, 1, 1, 100, TRUE). This single formula will instantly fill 20 rows and 1 column with whole numbers between 1 and 100.
- For Whole Numbers (Integers): Use the
- Press Enter: Once you have typed your chosen formula into the first cell, press the Enter key. You will see one random number appear in that cell.
- Fill the Range to 20 Cells:
- Click back onto the cell containing the formula to select it.
- Locate the Fill Handle, which is the small green square in the bottom-right corner of the selected cell.
- Click and hold the fill handle, then drag your mouse downward until you have covered 20 cells (for example, from A1 down to A20).
- Release the mouse button. Excel will automatically copy the formula into the other 19 cells, generating a unique random number for each.
- Freeze the Numbers (Optional but Recommended): By default, Excel formulas are "volatile." This means every time you type in another cell or refresh the sheet, all 20 random numbers will change. To stop this:
- Highlight the 20 cells containing your random numbers.
- Right-click and select Copy (or press Ctrl+C).
- Right-click on the same selection again.
- Under Paste Options, select the icon for Values (it looks like a clipboard with "123" on it). This replaces the formulas with the actual numbers, locking them in place.
Common Mistakes
One of the most frequent errors is forgetting that RANDBETWEEN allows for duplicates. If you generate 20 numbers between 1 and 100, it is mathematically possible to get the number 42 twice. If your project requires 20 unique numbers (no repeats), using RANDBETWEEN alone will not work. You would instead need to create a list of all possible numbers in a column, use =RAND() in the column next to it, and then sort the data by the random column to shuffle the list.
Another common mistake is failing to "Paste as Values." Users often spend time generating the perfect set of numbers, only to accidentally hit the Delete key or enter data in a nearby cell, causing the entire list to recalculate and change. Always lock your numbers if they are intended for a final report or a permanent draw.
Some users also confuse RAND with RANDBETWEEN. Using =RAND(1, 100) will result in an error because the RAND function does not accept arguments inside the parentheses. Remember: RAND() is for decimals; RANDBETWEEN(min, max) is for whole numbers.
Tips
To generate random decimals within a specific range (for example, between 5.5 and 10.5), you can use a mathematical modifier with the RAND() function. The formula would be =RAND() * (10.5 - 5.5) + 5.5. This tells Excel to take a random decimal between 0 and 1, multiply it by the difference between your max and min, and then add the minimum value.
If you are using a very large dataset and find that dragging the fill handle is too slow, you can select the target range first. Click cell A1, hold Shift, and click cell A20. While the range is highlighted, type your formula and press Ctrl + Enter. This will populate all 20 cells simultaneously without needing to drag the mouse.
For those using the RANDARRAY function in newer versions of Excel, you can control the precision of your numbers. By changing the last argument from TRUE (which gives integers) to FALSE, Excel will provide random decimals. This is incredibly useful for creating simulated financial data or scientific measurements.
Troubleshooting
The numbers won't change: If you enter the formula and the number stays the same even when you edit other cells, you may have "Manual Calculation" turned on. Go to the Formulas tab, click Calculation Options, and ensure Automatic is selected. Alternatively, you can press the F9 key to force a recalculation of all random functions.
The formula shows as text: If you see =RANDBETWEEN(1,100) written in the cell instead of a number, the cell is likely formatted as "Text." Right-click the cell, select Format Cells, change the category to General, and then double-click the cell and press Enter to reactivate the formula.
The #NUM! error appears: This usually happens if the bottom value in your RANDBETWEEN formula is larger than the top value (e.g., =RANDBETWEEN(100, 1)). Ensure the first number in the parentheses is the smaller number and the second is the larger one.
The #NAME? error appears: This occurs if the function is misspelled or if you are using a function (like RANDARRAY) that is not supported by your specific version of Excel. If you see this, try using the older RANDBETWEEN method instead.
Frequently Asked Questions
Can I generate random numbers that don't repeat?
The RANDBETWEEN function can produce duplicates. To get unique numbers, create a list of all possible numbers, assign a =RAND() value to each, and then sort the list by the random values. Take the top 20 results from that sorted list.
How do I make the random numbers stop changing?
You must copy the cells and use Paste Special > Values. This removes the underlying formula and leaves only the resulting number, preventing it from updating every time the sheet recalculates.
Does Excel have a way to generate random letters?
Yes, but it requires a combination of functions. You can use =CHAR(RANDBETWEEN(65, 90)) to generate a random uppercase letter, as 65 through 90 are the ASCII codes for A through Z.
Is there a limit to how many random numbers I can generate?
You can generate as many as there are cells in your worksheet. However, having thousands of volatile functions (like RAND) can slow down your computer's performance because Excel recalculates them constantly.
Can I use these numbers for professional security or encryption?
No. Excel's random functions are "pseudo-random," meaning they are generated by an algorithm and are not cryptographically secure. They are great for data sampling and games, but not for high-security encryption.
What is the difference between RAND and RANDBETWEEN?
RAND() generates a decimal between 0 and 1. RANDBETWEEN(bottom, top) generates a whole number between the two specific integers you provide as arguments.