To generate random numbers between a specific range in Excel, use the =RANDBETWEEN(bottom, top) formula, where "bottom" is the lowest number and "top" is the highest number you want. For example, =RANDBETWEEN(1, 100) will give you a whole number between 1 and 100. This is useful for creating sample data, picking winners for a giveaway, or simulating random outcomes for testing.

What You'll Need

  • A computer with Microsoft Excel installed (any version) or a web browser using Excel for the Web.
  • A basic understanding of how to click into a cell and type a formula.

Step-by-Step

  1. Select your cell: Click on the cell where you want the random number to appear. If you need a list of random numbers, select the first cell in the range where the list will start.
  2. Enter the formula: Type =RANDBETWEEN(` into the cell.
  3. Define the bottom range: Type the lowest number you want to be possible, followed by a comma. For example, if you want numbers between 10 and 50, type 10,.
  4. Define the top range: Type the highest number you want to be possible. Following the previous example, type 50.
  5. Close and execute: Type the closing parenthesis ) and press Enter. Your cell will now display a random whole number between those two values.
  6. Fill the range (Optional): If you need more than one random number, click the small green square (fill handle) in the bottom-right corner of the cell and drag it down or across to fill other cells. Each cell will generate its own unique random number.

Common Mistakes

  • Forgetting the equals sign: If you type RANDBETWEEN(1,10) without the = at the start, Excel treats it as plain text rather than a mathematical command.
  • Using decimals in RANDBETWEEN: The RANDBETWEEN function only returns integers (whole numbers). If you enter =RANDBETWEEN(1.5, 5.5), Excel will truncate the decimals and treat it as =RANDBETWEEN(1, 5).
  • Swapping the range order: While modern versions of Excel may handle this, it is best practice to always put the smaller number first and the larger number second to avoid calculation errors.
  • Assuming the numbers are static: A common mistake is forgetting that these formulas are "volatile." This means the numbers will change every single time you edit any cell in the workbook or press F9.

Tips

  • Freeze your numbers: If you want to keep the random numbers from changing, select the cells, copy them (Ctrl + C), right-click the same area, and select Paste Values (the icon with "123"). This replaces the formula with the actual number.
  • Generating decimals: If you need random numbers with decimals (e.g., between 1.0 and 5.0), use the =RAND() function. To get a decimal between a specific range, use the formula: =RAND()*(top-bottom)+bottom.
  • Using RANDARRAY for bulk data: If you have Microsoft 365, use =RANDARRAY(rows, cols, min, max, integer). For example, =RANDARRAY(10, 1, 1, 100, TRUE) instantly creates a column of 10 random whole numbers between 1 and 100.
  • Preventing duplicates: RANDBETWEEN can produce the same number multiple times. To get a list of unique random numbers, it is often easier to list your range of numbers in one column, use =RAND() in the next column, and then sort the data by the random column.

Troubleshooting

If the formula is not working as expected, try these steps in order:

  • Check for #NAME? error: This usually means the function name is misspelled. Ensure it is written exactly as RANDBETWEEN.
  • Check for #NUM! error: This happens if the "bottom" number is larger than the "top" number. Ensure your lowest value comes first.
  • Check Cell Formatting: If the cell shows the formula instead of the result, the cell might be formatted as "Text." Change the cell format to "General" via the Home tab and press Enter in the formula bar again.
  • Stop the numbers from changing: If the numbers change every time you type, remember to use the Paste Values method mentioned in the Tips section to lock them in.

Frequently Asked Questions

Can I generate random dates between two specific days?

Yes. Because Excel stores dates as numbers, you can use =RANDBETWEEN(DATE(2023,1,1), DATE(2023,12,31)). Just make sure to format the resulting cell as a "Date" instead of a "Number."

Is there a way to pick a random name from a list?

Yes. Use a combination of INDEX and RANDBETWEEN. For a list in cells A1 to A10, use: =INDEX(A1:A10, RANDBETWEEN(1, 10)).

How do I generate a random number that isn't a whole number?

Use the RAND() function. By itself, =RAND() gives a number between 0 and 1. To get a number between 1 and 10 with decimals, use =RAND()*(10-1)+1.

Why do my random numbers change every time I press Enter?

This is because RANDBETWEEN is a volatile function. It recalculates every time the worksheet changes. To stop this, copy the cells and "Paste as Values."

Does RANDBETWEEN include the bottom and top numbers?

Yes, the range is inclusive. If you use =RANDBETWEEN(1, 5), the result can be 1, 2, 3, 4, or 5.