Menu

Random Numbers in Excel: RAND, RANDBETWEEN, RANDARRAY

=RANDBETWEEN(1,100) returns a random whole number from 1 to 100, and =RAND() a random decimal from 0 up to 1. RANDARRAY fills a whole range, INDEX with RANDBETWEEN picks a random item, and Paste Special > Values freezes the results.

Every sheet on this page is live: change a number or a formula and it recalculates.

=RANDBETWEEN(1,100) returns a random whole number from 1 to 100, both ends included. =RAND() returns a random decimal that is at least 0 and less than 1. Both give new numbers every time the sheet recalculates.

Random numbers
B2
AB
1FormulaResult
2Decimal 0 to 10.256679579
3Whole 1 to 10024
4Die roll4
5CoinTails
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Edit any cell (type a word in A6, for example) and every result changes. In Excel the same happens on every edit anywhere in the workbook, and F9 forces a new set. The numbers you see here are not the ones another reader sees.

RAND and RANDBETWEEN syntax

=RAND()
=RANDBETWEEN(bottom, top)

RAND takes no arguments; the empty parentheses are required. RANDBETWEEN takes the smallest and largest whole number it may return, and returns #NUM! if bottom is larger than top.

Random number between two values

RANDBETWEEN only returns whole numbers. For a random decimal in a range, scale RAND: multiply by the width of the range and add the lowest value. Wrap it in ROUND to keep two decimals.

Random values in a range
D2
ABCD
1MinMaxKindRandom value
21050Whole46
31050Decimal49.74
42026-01-012026-12-31Date2026-09-04
5-55Whole-5
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Change the min and max in columns A and B and the results stay inside the new range. Dates are whole numbers in Excel, so RANDBETWEEN between two dates returns a random date; format the cell as a date (Home > Number Format > Short Date) or it shows a serial number. Negative bounds work too.

RANDARRAY: many random numbers at once

In Excel 365 and Excel 2021, =RANDARRAY(rows, columns, min, max, whole_number) fills a whole range from one cell. Every argument is optional: =RANDARRAY(5) gives five decimals from 0 to 1 down a column.

RANDARRAY spills a block of numbers
A2
ABCD
1Whole numbers 1 to 100Decimals 0 to 1
26423310.040617832
38389550.480702855
49578920.305043489
5436920.133745562
64473640.581903097
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

A2 fills A2:C6 with whole numbers (the last argument, TRUE, asks for whole numbers; leave it out for decimals). Excel 2019 and earlier have no RANDARRAY: write =RANDBETWEEN(1,100) in one cell and fill it across the range.

Pick a random item from a list

To draw a random name, product or question, pick a random position with RANDBETWEEN and return the item at that position with INDEX. COUNTA counts the names, so the range can run past the list into empty rows: =INDEX(A2:A100,RANDBETWEEN(1,COUNTA(A2:A100))) keeps working as you add names below.

Random winner
C2
ABC
1NameWinner
2AnaFinn
3Ben
4Cleo
5Dan
6Eve
7Finn
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Each name has the same chance, one in six. Two cells with this formula can draw the same name; for several different winners, shuffle the list instead (next section) and take the top rows.

Shuffle a list and random numbers without repeats

=SORTBY(A2:A7,RANDARRAY(6)) sorts the list by six random numbers, which puts it in random order. Because each item appears once, the result never repeats, which is the standard way to draw several different names or numbers in Excel 365 and 2021.

Shuffled list and 3 different numbers from 1 to 20
C2
ABCDE
1NameShuffled3 of 1 to 20
2AnaFinn8
3BenBen3
4CleoAna12
5DanCleo
6EveEve
7FinnDan
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

E2 shuffles the numbers 1 to 20 made by SEQUENCE and keeps the first three with TAKE, so the three are always different. TAKE needs Microsoft 365 or Excel 2024; in Excel 2021 write =INDEX(SORTBY(SEQUENCE(20),RANDARRAY(20)),SEQUENCE(3)). In Excel 2019, put =RAND() in a helper column next to the list and sort the list by that column with Data > Sort.

Try it: scale a random value yourself

RANDBETWEEN is RAND scaled to a range and cut to a whole number. Here B2 holds a value that RAND once returned, pasted as a value so it no longer changes.

Turn a RAND value into a whole number
C2
ABCDE
1ItemRAND valueWhole numberMinMax
2Draw 10.372512
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: B2 holds a value from RAND. In C2, turn it into a whole number from the min in D2 to the max in E2, both included, the way RANDBETWEEN does: multiply by the count of possible numbers, drop the decimals with INT, and add the min.

Hint: from 5 to 12 there are E2-D2+1 possible numbers, which is 8.

Common mistake: results that change after you use them

A random draw that changes on the next edit is useless as a record of who won or which rows went into a sample. Once you have the numbers you want, turn them into values:

  1. Select the cells and copy them (Ctrl+C, Cmd+C on a Mac).
  2. Home > Paste > Values. On Windows, Ctrl+Alt+V, then V, then Enter; on a Mac, Ctrl+Cmd+V and pick Values.

For a single cell, press F2 to edit it, F9 to replace the formula with its current result, and Enter. If you need the same "random" numbers every time, for a test or a class exercise, there is no seed argument in Excel: paste values once and keep that sheet. RAND is fine for samples, games and test data but not for passwords or anything security related.

Frequently Asked Questions

How do I generate a random number between two numbers in Excel?

For whole numbers use =RANDBETWEEN(10,50), which can return both 10 and 50. For decimals use =RAND()*(50-10)+10, or =RANDARRAY(1,1,10,50) in Excel 365 or 2021.

How do I stop random numbers from changing in Excel?

Replace the formulas with their values: copy the cells, then Home > Paste > Values. On Windows, Ctrl+Alt+V, V, Enter does the same; on a Mac, Ctrl+Cmd+V opens Paste Special, where you pick Values. For one cell, press F2, then F9 (Fn+F9 on some laptops), then Enter.

How do I pick a random name from a list in Excel?

Use =INDEX(A2:A7,RANDBETWEEN(1,COUNTA(A2:A7))). COUNTA counts the names, RANDBETWEEN picks a position and INDEX returns the name at that position.

How do I generate random numbers without duplicates in Excel?

Shuffle a sequence and take the first few: =TAKE(SORTBY(SEQUENCE(50),RANDARRAY(50)),6) gives 6 different numbers from 1 to 50 in Excel 365. In Excel 2021, which has no TAKE, use =INDEX(SORTBY(SEQUENCE(50),RANDARRAY(50)),SEQUENCE(6)). RANDBETWEEN in several cells can repeat.

How do I generate a random date in Excel?

Use RANDBETWEEN with two dates: =RANDBETWEEN(DATE(2026,1,1),DATE(2026,12,31)) returns a random day of 2026. Format the cell as a date, or it shows the date's serial number.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED