How to Generate Random Numbers in Excel

For a whole number between 1 and 100, give RANDBETWEEN the smallest and largest numbers. Both ends (1 and 100) can come up.

Formula to use

=RANDBETWEEN(1, 100)

One whole number from 1 to 100

When you need a decimal

RAND returns a decimal greater than or equal to 0 and less than 1. To stretch it to a range, multiply by (max − min) and add the minimum. Use ROUND to set the number of decimal places.

  • =RAND()0 or more, less than 1
  • =RAND()*(100-50)+50A decimal from 50 up to (not including) 100
  • =ROUND(RAND()*100, 2)0 to 100, two decimal places

Keep the values from changing

RAND and RANDBETWEEN return new values every time the sheet recalculates, such as when you type in another cell or press F9.

To keep the numbers you got, copy the cells and use Paste Special > Values in the same place. The formulas disappear and only the numbers remain.

Pick a random item from a list

Use RANDBETWEEN to pick a position from 1 to the length of the list, and INDEX to return the item at that position. Counting the length with ROWS means you do not have to change a number when the range changes.

  • =INDEX(A2:A11, RANDBETWEEN(1, ROWS(A2:A11)))One item from A2:A11 at random

Shuffle a list (a draw without repeats)

RANDBETWEEN in several cells can repeat numbers. For positions that do not repeat, put RAND in a helper column and rank those values. Sort by the rank column and the list is shuffled.

  • =RAND()In column B, copied down
  • =RANK(B2, $B$2:$B$11)Column C: random positions 1 to 10

Try the functions used here

Change the arguments in the function playground and watch the calculation step by step.

  • RANDBETWEEN functionReturns a random integer between two numbers.
  • RAND functionReturns a random number from 0 up to (but not including) 1. It changes on every recalculation.
  • INDEX functionReturns the value at a given row and column position inside a range.
  • RANK functionReturns the rank of a value within a range. A compatibility function that calculates the same as RANK.EQ.

FAQ

Can the range include negative numbers?
Yes. =RANDBETWEEN(-10, 10) returns a whole number from -10 to 10.
Can two RANK positions be the same?
Only if two RAND values are exactly equal, which almost never happens because they have so many decimal places. After sorting, check once that the positions run from 1 with no gaps.
I do not want the numbers to change every time I open the file.
Pasting them as values is the simplest way to fix them.

More guides