=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.
| A | B | |
|---|---|---|
| 1 | Formula | Result |
| 2 | Decimal 0 to 1 | 0.256679579 |
| 3 | Whole 1 to 100 | 24 |
| 4 | Die roll | 4 |
| 5 | Coin | Tails |
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.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Min | Max | Kind | Random value |
| 2 | 10 | 50 | Whole | 46 |
| 3 | 10 | 50 | Decimal | 49.74 |
| 4 | 2026-01-01 | 2026-12-31 | Date | 2026-09-04 |
| 5 | -5 | 5 | Whole | -5 |
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.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Whole numbers 1 to 100 | Decimals 0 to 1 | ||
| 2 | 64 | 23 | 31 | 0.040617832 |
| 3 | 83 | 89 | 55 | 0.480702855 |
| 4 | 95 | 78 | 92 | 0.305043489 |
| 5 | 4 | 36 | 92 | 0.133745562 |
| 6 | 44 | 73 | 64 | 0.581903097 |
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.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Winner | |
| 2 | Ana | Finn | |
| 3 | Ben | ||
| 4 | Cleo | ||
| 5 | Dan | ||
| 6 | Eve | ||
| 7 | Finn |
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.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | Shuffled | 3 of 1 to 20 | ||
| 2 | Ana | Finn | 8 | ||
| 3 | Ben | Ben | 3 | ||
| 4 | Cleo | Ana | 12 | ||
| 5 | Dan | Cleo | |||
| 6 | Eve | Eve | |||
| 7 | Finn | Dan |
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.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Item | RAND value | Whole number | Min | Max |
| 2 | Draw 1 | 0.372 | 5 | 12 |
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:
- Select the cells and copy them (Ctrl+C, Cmd+C on a Mac).
- 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.