Random numbers and number lists: practice exercises
RANDBETWEEN, RAND, SEQUENCE for numbering and dates, RANDARRAY, F9 to recalculate. 7 exercises on real-looking data, each marked the moment you press Check. The first exercise is below to try now; the full lesson is part of Pro.
Roll a dice ten times. In B2, use RANDBETWEEN to give a random whole number from 1 to 6, and copy it down to B11.
| A | B | C | |
|---|---|---|---|
| 1 | Roll | Dice | Player |
| 2 | 1 | Chen | |
| 3 | 2 | Owen | |
| 4 | 3 | Sunil | |
| 5 | 4 | Ivan | |
| 6 | 5 | Ben | |
| 7 | 6 | Hamza | |
| 8 | 7 | Ella | |
| 9 | 8 | Ollie | |
| 10 | 9 | Tanya | |
| 11 | 10 | Sam |
How it works
RANDBETWEEN(bottom, top) gives a random whole number from the bottom to the top: =RANDBETWEEN(1,6) rolls a dice. Every time the sheet recalculates (press F9, or change any cell) you get new numbers. That's handy for practice data and draws.
SEQUENCE(rows) numbers a list 1, 2, 3 … from one formula, and spills down. Add columns, a start and a step: =SEQUENCE(10,1,100,5) gives 100, 105 … 145. RANDARRAY is the random one: a whole block of random numbers at once.
=RANDBETWEEN(1,10) =SEQUENCE(5) =SEQUENCE(10,1,E1,7) =RANDARRAY(5,3,1,100,TRUE)
RANDBETWEEN and RAND
=RANDBETWEEN(1,6) picks a whole number from 1 to 6, like a dice roll. Copied down ten rows, it gives ten rolls.
The bottom and top can be cells: =RANDBETWEEN($E$1,$E$2) with 40 in E1 and 100 in E2 gives made-up scores from 40 to 100. Lock them with $ so they stay put when the formula is copied.
=RAND() has nothing in its brackets and gives a decimal from 0 up to (not including) 1, such as 0.4182. It's handy for shuffling: put RAND next to a list and sort by it.
Random numbers change each time Excel recalculates: when you type in any cell, or press F9. To keep a set, paste them back as values.
Worked example: numbering with SEQUENCE
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Week | Starts | |||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 | |||||
| 6 | Start | 04/01/2027 |
=SEQUENCE(4)in A2. One formula in A2, and the numbers 1, 2, 3, 4 spill down. Add a row to the list and change the 4 to 5.=SEQUENCE(4,1,10,10)in A2. SEQUENCE(rows, columns, start, step): 4 rows, 1 column, starting at 10, going up in 10s gives 10, 20, 30, 40.=SEQUENCE(4,1,E6,7)in A2. Dates are numbers too: start at the date in E6 and go up 7 a time for the start of each week. Format the cells as dates to see them as dates.
RANDARRAY
RANDARRAY(rows, columns, bottom, top, whole) fills a block with random numbers from one formula, the way SEQUENCE does with a list. =RANDARRAY(8,3,1,100,TRUE) in A2 fills A2:C9 with whole numbers from 1 to 100.
- Leave out the bottom and top and you get decimals from 0 to 1, like RAND.
- The last part, TRUE, asks for whole numbers. Leave it out (or put FALSE) for decimals.
- Like every spilled list, it needs empty cells to spill into, or it shows #SPILL!.
Windows: Formulas tab, Calculate Now recalculates, the same as F9.
Mac: Formulas tab, Calculate Now; F9 may need the Fn key held as well.
What you'll practise
- Roll a dice ten times. In B2, use RANDBETWEEN to give a random whole number from 1 to 6, and copy it down to B11.
- Make up practice scores to test a mark sheet with. In B2, give a random whole number between the lowest score in E1 and the highest in E2. Lock E1 and E2 with $ so the formula can be copied down to B13.
- Number the 12 raffle prizes. In A2, use SEQUENCE to list 1 to 12 from one formula. It spills down by itself.
- In B2, use SEQUENCE to list the date each of the 10 weeks starts: from the date in F1, going up 7 days at a time. SEQUENCE(rows, columns, start, step).
- Fill A2:C9 with practice marks from one formula in A2: RANDARRAY with 8 rows, 3 columns, from 1 to 100, and TRUE at the end for whole numbers.
- Give each new starter a temporary four-digit PIN: in C2:C13, generate a random whole number from 1000 to 9999.
- Seats are numbered in tens. Enter a single formula in A2 that fills A2:A21 with the numbers 10, 20, 30 and so on, up to 200.