To generate random numbers in Excel, use the =RAND() function for a decimal between 0 and 1, or the =RANDBETWEEN(bottom, top) function for a whole number between two specific values. These functions allow you to create sample data, assign random IDs, or pick winners from a list quickly and efficiently.

What You'll Need

  • A computer with Microsoft Excel installed (works across Windows, macOS, and Web versions).
  • A basic understanding of how to enter a formula into a cell.
  • A defined range of numbers if you intend to use the RANDBETWEEN function.

Step-by-Step

Method 1: Generating Decimals with RAND

The RAND function is the simplest way to get a random value. It requires no arguments and always returns a number greater than or equal to 0 and less than 1.

  1. Open your Excel workbook and click on the cell where you want the random number to appear.
  2. Type =RAND() exactly as shown, including the empty parentheses.
  3. Press Enter. Excel will populate the cell with a decimal (e.g., 0.45231).
  4. To apply this to multiple cells, click the small green square (fill handle) at the bottom-right corner of the cell and drag it down or across the desired range.

Method 2: Generating Whole Numbers with RANDBETWEEN

If you need a specific range—such as a random number between 1 and 100—the RANDBETWEEN function is the correct tool.

  1. Select the cell where you want the integer to appear.
  2. Type =RANDBETWEEN(.
  3. Enter the lowest possible number you want (the bottom), followed by a comma. For example, if you want numbers starting at 1, type 1,.
  4. Enter the highest possible number you want (the top). For example, if the limit is 100, type 100.
  5. Close the parentheses and press Enter. The final formula should look like =RANDBETWEEN(1,100).
  6. Use the fill handle to drag the formula across other cells to generate a list of random integers.

Method 3: Generating Random Decimals within a Specific Range

Since RAND() only gives values between 0 and 1, you must use a mathematical formula to scale that number to a custom range (e.g., between 10.5 and 20.5).

  1. Identify your minimum value (Low) and your maximum value (High).
  2. In a cell, enter the formula: =RAND() * (High - Low) + Low.
  3. For example, to get a random decimal between 10 and 50, you would enter =RAND() * (50 - 10) + 10.
  4. Press Enter and drag the fill handle to create more values.

Method 4: Freezing the Random Numbers

By default, random functions in Excel are "volatile." This means every time you type in any cell or recalculate the sheet, the random numbers change. To stop this, you must convert the formulas into static values.

  1. Highlight the cells containing your random numbers.
  2. Right-click and select Copy (or press Ctrl + C).
  3. Right-click on the same selection of cells.
  4. Under Paste Options, select the icon that looks like a clipboard with "123" on it (Paste Values).
  5. The formulas are now gone, and the numbers will remain permanent.

Common Mistakes

One of the most frequent errors is forgetting the parentheses in the =RAND() function. Even though the function takes no arguments, Excel requires the parentheses to recognize it as a function rather than a named range or text. If you omit them, you will likely see a #NAME? error.

Another common mistake is using RANDBETWEEN when you actually need unique numbers. RANDBETWEEN does not track which numbers it has already generated. If you generate 10 random numbers between 1 and 10, it is highly likely that some numbers will repeat and others will be missing. If you need a unique list (a random shuffle), you should instead list your numbers in one column, use =RAND() in the next column, and then sort the data based on the random decimal column.

Users also frequently forget to "freeze" their data. If you use random numbers to assign participants to a study group or to pick a winner for a contest, and then you accidentally delete a row elsewhere in the sheet, all your random assignments will change instantly. Always use Paste Values to lock in your results before relying on them for final decisions.

Tips

To create a random date, remember that Excel treats dates as whole numbers. You can use RANDBETWEEN by entering the start date and end date as references to cells that contain dates. For example, if cell A1 has 01/01/2023 and B1 has 12/31/2023, the formula =RANDBETWEEN(A1, B1) will give you a random date within that year. Just make sure to format the result cell as a "Date" instead of a "Number."

If you are using a modern version of Excel (Microsoft 365), you can use the =RANDARRAY() function. This is a powerful dynamic array function that can generate a whole table of random numbers at once. For example, =RANDARRAY(10, 5, 1, 100, TRUE) will create a grid 10 rows high and 5 columns wide, with whole numbers between 1 and 100. This eliminates the need to drag the fill handle manually.

To generate a random item from a list, combine INDEX and RANDBETWEEN. If your list of names is in cells A1 through A10, use the formula =INDEX(A1:A10, RANDBETWEEN(1, 10)). This tells Excel to look at the range A1:A10 and pick the item at a random position between 1 and 10.

Troubleshooting

If your formula returns a #NUM! error, check your RANDBETWEEN arguments. This usually happens if the "bottom" number is larger than the "top" number (e.g., =RANDBETWEEN(100, 1)). Ensure the smaller number always comes first.

If the numbers are not changing when you want them to, check if your Calculation Options are set to Manual. Go to the Formulas tab, click Calculation Options, and ensure Automatic is selected. If it is set to Manual, the random numbers will only update when you press F9.

If you see a #VALUE! error, ensure that the arguments in your function are actual numbers and not text. If you are referencing cells for your range, make sure those cells don't contain letters or hidden spaces that Excel might interpret as text.

Frequently Asked Questions

Can I generate a random number that is not a whole number?

Yes. Use the =RAND() function for a value between 0 and 1, or use the formula =RAND() * (Max - Min) + Min to get a random decimal between any two specific numbers.

How do I stop the numbers from changing every time I edit the sheet?

You must copy the cells and then use "Paste Values." This replaces the live formula with the resulting number, making it permanent.

Is there a way to generate a list of random numbers without duplicates?

The RANDBETWEEN function can produce duplicates. To get unique numbers, create a list of your available numbers, use =RAND() in the adjacent column, and then sort the entire range by the random column.

Does the RAND function work in Google Sheets too?

Yes, the =RAND() and =RANDBETWEEN() functions work identically in Google Sheets as they do in Microsoft Excel.

How can I generate a random letter?

You can use the CHAR function combined with RANDBETWEEN. For a random uppercase letter (A-Z), use =CHAR(RANDBETWEEN(65, 90)), as these are the ASCII codes for uppercase letters.