How to Use the RANDBETWEEN Function in Microsoft Excel

If you are a teacher building a math quiz, a manager selecting a random winner for a company raffle, or an analyst who needs to fill a blank spreadsheet with hundreds of “dummy” data points to test a chart, manually typing in random numbers takes hours.

Microsoft Excel can generate random numbers for you instantly using the RANDBETWEEN function. This function allows you to set a strict floor and ceiling, ensuring the numbers always fall perfectly within your required range.

Understanding the Syntax

The RANDBETWEEN function requires exactly two arguments: the lowest possible number, and the highest possible number.

Syntax: =RANDBETWEEN(bottom, top)

  • bottom: The smallest integer (whole number) you want Excel to generate.
  • top: The largest integer you want Excel to generate.

Example 1: Generating Lottery Numbers

Imagine you are running an office raffle. You sold 500 tickets, numbered 1 through 500, and you need Excel to pick a completely random winner.

  1. Click an empty cell in your spreadsheet.
  2. Type the formula: =RANDBETWEEN(1, 500)
  3. Press Enter.

Excel will instantly output a random number, such as 342. (Note: RANDBETWEEN is inclusive, meaning it is mathematically possible for it to pick exactly 1 or exactly 500).

Example 2: Generating Negative Numbers

This function works perfectly with negative numbers, which is incredibly useful for simulating financial data where a company might have a profit or a loss.

If you want to simulate monthly revenue fluctuations between a $1,000 loss and a $5,000 profit, you would type:

=RANDBETWEEN(-1000, 5000)

The Recalculation Trap (Important Warning)

RANDBETWEEN is what Excel calls a “volatile” function. This means that every single time you edit any cell anywhere in your spreadsheet, Excel recalculates the entire workbook, and your random numbers will instantly change to brand new random numbers.

If you use =RANDBETWEEN(1,10) to simulate student test scores, and then you start typing in column C to write a summary, the test scores will rapidly mutate with every keystroke.

How to lock the numbers permanently:

Once you generate your random data, you must “freeze” it so it stops changing.

  1. Highlight all the cells containing your RANDBETWEEN formulas.
  2. Press Ctrl + C (Command + C on Mac) to copy them.
  3. Right-click on the exact same highlighted area.
  4. Under the Paste Options menu, click the icon that looks like a clipboard with the numbers 123 on it (This is “Paste Values”).

This deletes the underlying RANDBETWEEN formula and replaces it with the permanent, static number that was just generated, preventing it from ever changing again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.