RANDARRAY
ASELECT.MATRIX in Dutch Excel
Fills a block of any size with random numbers, decimals or whole numbers between bounds you choose, and draws them again on every recalculation.
Last updated: 13 October 2026
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Relation | Customer | Balance 31 Dec 2025 | Draw |
| 2 | D1001 | Brinkman Installatie BV | €12,450.00€ 12.450,00 | 0.73160,7316=RANDARRAY(5)=RANDARRAY(5) |
| 3 | D1002 | Bakkerij De Gouden Korst BV | €3,820.50€ 3.820,50 | 0.20890,2089 |
| 4 | D1003 | Hoekstra Transport BV | €27,915.75€ 27.915,75 | 0.55470,5547 |
| 5 | D1004 | Van der Meer Groenteteelt | €1,640.00€ 1.640,00 | 0.09120,0912 |
| 6 | D1005 | Kuiper Metaalbewerking BV | €8,095.20€ 8.095,20 | 0.88030,8803 |
Swipe sideways to see all columns
=RANDARRAY(5)
=RANDARRAY(5)
What RANDARRAY does and when to use it
What it does: it fills a whole block of random numbers from one cell, with the rows, columns, minimum and maximum you choose, as decimals or whole numbers, for example a random key per invoice.
When to use it: to fill a test sheet, shuffle a list with SORTBY, draw a sample or simulate many outcomes at once. For one random whole number RANDBETWEEN is shorter and works in every Excel version.
Three main gains:
- One formula, whole block: the result spills over the
rowsandcolumnsyou set, with no formula to copy down. - Range built in:
minandmaxreplace the scaling sum you need with RAND. - Whole numbers on request: set
whole_numberto TRUE instead of rounding the result.
How Excel evaluates it
Excel works as follows:
- it reads the five arguments, filling in 1, 1, 0, 1 and FALSE for any you leave out, and checks that min is not above max
- it draws every cell of the rows by columns block independently: a decimal between min and max, or with whole_number TRUE a whole number from min to max with both ends possible
- it spills the block from the formula cell
Watch out: Every recalculation, from any edit in the workbook, opening the file or pressing F9, draws a completely new block, and there is no seed to get the same numbers back. Freeze a draw that matters with Copy and Paste Values.
Mental model
A tray of dice, one per cell, thrown together every time anyone touches the workbook; each die lands on its own, so two can show the same face.
Terms used on this page: workbook, spill, argument, range, cell
Syntax
RANDARRAY([rows],[columns], [min], [max], [whole_number])
RANDARRAY([rows];[columns]; [min]; [max]; [whole_number])
| Argument | Type | Meaning | Default |
|---|---|---|---|
rows | Optional | How many rows of random numbers; default 1. | 1 |
columns | Optional | How many columns of random numbers; default 1. | 1 |
min | Optional | The lowest value allowed; default 0. | 0 |
max | Optional | The highest value allowed; default 1. | 1 |
whole_number | Optional | TRUE for whole numbers; FALSE or omitted for decimals. | FALSE |
Return value:A spilled block of rows by columns random numbers
Formulas use commas (,) between arguments, as in English Excel. Formulas use semicolons (;) between arguments, as in Dutch Excel. Formulas use commas (,) between arguments, as in English Excel; Dutch Excel uses semicolons (;).
Worked examples
Beginner
Draw a follow-up order for debtor confirmations
Sanne de Vries is auditing Veldhuis Installatie BV and has sent five debtor confirmations as of 31 December 2025. She wants a visible, unbiased way to decide which customer she chases first for a reply.
Each customer gets a random number; the lowest number is followed up first. She draws once, then freezes the result for the file.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Relation | Customer | Balance 31 Dec 2025 | Draw | |
| 2 | D1001 | Brinkman Installatie BV | €12,450.00€ 12.450,00 | 0.73160,7316=RANDARRAY(5)=RANDARRAY(5) | |
| 3 | D1002 | Bakkerij De Gouden Korst BV | €3,820.50€ 3.820,50 | 0.20890,2089 | |
| 4 | D1003 | Hoekstra Transport BV | €27,915.75€ 27.915,75 | 0.55470,5547 | |
| 5 | D1004 | Van der Meer Groenteteelt | €1,640.00€ 1.640,00 | 0.09120,0912 | |
| 6 | D1005 | Kuiper Metaalbewerking BV | €8,095.20€ 8.095,20 | 0.88030,8803 | |
| 7 |
Swipe sideways to see all columns
Formula in D2
=RANDARRAY(5)
=RANDARRAY(5)
Result: 0.7316 / 0.2089 / 0.5547 / 0.0912 / 0.88030,7316 / 0,2089 / 0,5547 / 0,0912 / 0,8803Random: your result will differ
Step by step
- Excel reads rows as 5. The other four arguments are left out, so columns is 1, min is 0, max is 1 and whole_number is FALSE.
- It draws 5 independent decimals between 0 and 1 and spills them from
D2toD6. Say it draws 0.7316, 0.2089, 0.5547, 0.0912 and 0.8803 (shown to 4 decimals); your numbers will be different, and that is expected. - The lowest number is 0.0912 in
D5, next toD1004(Van der Meer Groenteteelt, balance 1,640.001.640,00), so that customer is chased first. ThenD1002(0.2089),D1003(0.5547),D1001(0.7316) andD1005(0.8803). - Type a note anywhere in the sheet and press Enter: all five numbers change, because every edit recalculates RANDARRAY. Once the order is final, copy
D2:D6and paste it as values onto itself, so the order in the audit file can be traced.
Watch out: If a sixth customer is added in row 7, RANDARRAY(5) still draws only five numbers and the new relation gets none. Use RANDARRAY(ROWS(A2:A7)) so the count follows the list.
More on this example: why it works, 1 variation
Why it works
One formula gives every customer its own independent number, and with decimals between 0 and 1 a tie is so unlikely that the order is clear. The draw is unbiased because no number depends on another, and freezing it turns a live draw into evidence in the file.
Variations
=RAND()
=RAND()
One random decimal in one cell, the older way: copy it down five rows to get the same effect without spilling.
Intermediate
A grid of whole test amounts for a round-amount test
Before the real journal lines of Veldhuis Installatie BV arrive, Sanne de Vries is building her journal entry testing sheet and needs test data: four entries with three lines each, whole amounts from 100 to 5,0005.000.
Both bounds must be possible, so the formulas that flag exact round amounts such as 100 and 5,0005.000 get tested too, and the amounts must be whole euros, as in the real export.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Entry no. | Line 1 | Line 2 | Line 3 | |
| 2 | 25-0412 | 12501250=RANDARRAY(4, 3, 100, 5000, TRUE)=RANDARRAY(4; 3; 100; 5000; TRUE) | 47304730 | 310310 | |
| 3 | 25-0413 | 50005000 | 28752875 | 100100 | |
| 4 | 25-0414 | 780780 | 34203420 | 34203420 | |
| 5 | 25-0415 | 41054105 | 50005000 | 260260 | |
| 6 |
Swipe sideways to see all columns
Formula in B2
=RANDARRAY(4,3, 100, 5000, TRUE)
=RANDARRAY(4;3; 100; 5000; TRUE)
Result: 1250 | 4730 | 310 / 5000 | 2875 | 100 / 780 | 3420 | 3420 / 4105 | 5000 | 2601250 | 4730 | 310 / 5000 | 2875 | 100 / 780 | 3420 | 3420 / 4105 | 5000 | 260Random: your result will differ
Step by step
- Excel reads rows 4 and columns 3, so the block is 4 by 3: one row per entry, one column per line,
B2toD5. - min is 100, max is 5000, and whole_number is TRUE, so each of the 12 cells gets a whole number from 100 to 5000, both included: 5000 - 100 + 1 = 4901 possible values per cell.
- Say it draws 1250, 4730, 310 for entry
25-0412; 5000, 2875, 100 for25-0413; 780, 3420, 3420 for25-0414; 4105, 5000, 260 for25-0415. Both bounds appear (100 once, 5000 twice), and25-0414has 3420 twice, because every cell is drawn on its own. - Leave out the fifth argument and the same block fills with decimals such as 2718.4392 and 100.0427, because whole_number defaults to FALSE. An exact 5,0005.000 then becomes practically impossible, so the round-amount test would never be tested.
- Press F9 and all 12 amounts change. When the testing sheet works, select
B2:D5and paste as values before you replace them with real journal lines.
Watch out: Typing a real amount into C3 while the formula is still live gives #SPILL! in B2, because the typed value blocks the spill range. Freeze the block first.
More on this example: why it works, 1 more pitfall, 1 variation
Why it works
The first two arguments shape the block to match the sheet, and the last three decide what goes in each cell. whole_number TRUE makes the bounds inclusive whole values, which is what euro amounts in an export are; without it the same bounds describe a continuous range of decimals.
More to watch out for
- Swapping min and max, RANDARRAY(4, 3, 5000, 100, TRUE), gives #VALUE!; min must not be larger than max.
Variations
=ROUND(RANDARRAY(4,3, 100, 5000), 2)
=ROUND(RANDARRAY(4;3; 100; 5000); 2)
Amounts with cents between 100 and 5,0005.000, closer to a real export: ROUND to 2 decimals keeps them at cent level.
Advanced
Shuffle invoices into a random testing order
Sanne de Vries has six sales invoices of Veldhuis Installatie BV that she will vouch to supporting documents, and she wants a random testing order that nobody can call selective. The list may still grow. She wants the shuffled invoice numbers in one column next to the list, and she will freeze the order once it is recorded in the audit file.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Invoice no. | Amount | Testing order | ||
| 2 | 25-1101 | €8,450.00€ 8.450,00 | 25-1105=SORTBY(A2:A7, RANDARRAY(ROWS(A2:A7)))=SORTBY(A2:A7; RANDARRAY(ROWS(A2:A7))) | ||
| 3 | 25-1102 | €1,275.50€ 1.275,50 | 25-1102 | ||
| 4 | 25-1103 | €23,900.00€ 23.900,00 | 25-1104 | ||
| 5 | 25-1104 | €640.75€ 640,75 | 25-1106 | ||
| 6 | 25-1105 | €5,180.00€ 5.180,00 | 25-1101 | ||
| 7 | 25-1106 | €11,320.40€ 11.320,40 | 25-1103 | ||
| 8 |
Swipe sideways to see all columns
Formula in D2
=SORTBY(A2:A7,RANDARRAY(ROWS(A2:A7)))
=SORTBY(A2:A7;RANDARRAY(ROWS(A2:A7)))
Result: 25-1105 / 25-1102 / 25-1104 / 25-1106 / 25-1101 / 25-110325-1105 / 25-1102 / 25-1104 / 25-1106 / 25-1101 / 25-1103Random: your result will differ
Step by step
- The innermost function first: ROWS(A2:A7) counts the rows of the list: 6.
- RANDARRAY(6) draws 6 decimals between 0 and 1, one per invoice. Say 0.6213 for
25-1101, 0.1534 for25-1102, 0.8846 for25-1103, 0.3419 for25-1104, 0.0702 for25-1105and 0.5127 for25-1106; yours will differ. - SORTBY uses those 6 numbers as by_array1 and sorts ascending: 0.0702, 0.1534, 0.3419, 0.5127, 0.6213, 0.8846.
- Each invoice follows its number:
25-1105,25-1102,25-1104,25-1106,25-1101,25-1103. They spill fromD2toD7; the random keys themselves never appear on the sheet. - Whatever the draw, the output always contains the same six invoice numbers exactly once, because sorting only reorders. Record the order, then copy
D2:D7and paste as values, or the next edit reshuffles it.
Watch out: Using whole numbers as keys, RANDARRAY(6, 1, 1, 6, TRUE), looks equivalent but produces ties in about 98% of draws. Tied invoices keep their list order, so those near the top of the list are silently favored.
More on this example: why it works, 1 more pitfall, 2 variations
Why it works
Giving every item an independent random key and sorting by it makes every ordering equally likely, which is what a fair shuffle means. ROWS ties the number of keys to the list, so the key array always has the size SORTBY demands.
More to watch out for
- Hard-coding RANDARRAY(6) works until a seventh invoice is added and the ranges are extended: then the key array is one short and the result is #VALUE!.
Variations
=TAKE(SORTBY(A2:A7,RANDARRAY(ROWS(A2:A7))), 3)
=TAKE(SORTBY(A2:A7;RANDARRAY(ROWS(A2:A7))); 3)
Only the first three of the shuffle: a random sample of 3 invoices to vouch first, never the same invoice twice.
=SORTBY(A2:B7,RANDARRAY(ROWS(A2:B7)))
=SORTBY(A2:B7;RANDARRAY(ROWS(A2:B7)))
Shuffle invoice numbers and amounts together, so each invoice keeps its amount.
MasterExcel 2024 or later (This example needs Excel 2024 or later)
Draw a sample of manual entries without repeats
In December 2025 Veldhuis Installatie BV posted 45 manual memorial entries (journal MEM), numbered 1 to 45 in the extract. Sanne de Vries tests six of them, one per test focus, and no entry may be selected twice, so the six numbers must all differ. The number of draws must follow the list of sample items, and the formula must say so plainly if someone adds more items than there are entries.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Item | Test focus | Entry to test | First entry | 11 | ||
| 2 | 11 | Round amount | 2727=LET( pool, SEQUENCE(F2 - F1 + 1, 1, F1), n, ROWS(B2:B7), shuffled, SORTBY(pool, RANDARRAY(ROWS(pool))), IF(n > ROWS(pool), "More items than entries", TAKE(shuffled, n)) )=LET( pool; SEQUENCE(F2 - F1 + 1; 1; F1); n; ROWS(B2:B7); shuffled; SORTBY(pool; RANDARRAY(ROWS(pool))); IF(n > ROWS(pool); "More items than entries"; TAKE(shuffled; n)) ) | Last entry | 4545 | ||
| 3 | 22 | Weekend posting | 33 | ||||
| 4 | 33 | Posted after period close | 4444 | ||||
| 5 | 44 | Unusual account pair | 1111 | ||||
| 6 | 55 | Year-end cut-off | 3838 | ||||
| 7 | 66 | No description | 1919 | ||||
| 8 |
Swipe sideways to see all columns
Formula in C2
=LET( pool,SEQUENCE(F2 - F1 + 1, 1, F1), n, ROWS(B2:B7), shuffled, SORTBY(pool, RANDARRAY(ROWS(pool))), IF(n > ROWS(pool), "More items than entries", TAKE(shuffled, n)) )
=LET( pool;SEQUENCE(F2 - F1 + 1; 1; F1); n; ROWS(B2:B7); shuffled; SORTBY(pool; RANDARRAY(ROWS(pool))); IF(n > ROWS(pool); "More items than entries"; TAKE(shuffled; n)) )
Result: 27 / 3 / 44 / 11 / 38 / 1927 / 3 / 44 / 11 / 38 / 19Random: your result will differ
Step by step
- pool is SEQUENCE(45 - 1 + 1, 1, 1): a column of the 45 entry numbers 1, 2, 3 and so on up to 45. Each number exists once.
- n is ROWS(B2:B7): 6 sample items, so 6 draws. Add an item in row 8, extend the range, and n becomes 7 without touching the rest.
- shuffled sorts pool by RANDARRAY(45), 45 random decimals: one random key per entry. The result is all 45 numbers in a random order, still each exactly once.
- IF checks 6 > 45, which is FALSE, so TAKE(shuffled, 6) keeps the first six of the shuffle. Say they are 27, 3, 44, 11, 38 and 19; your draw will differ, but it will always be 6 different whole numbers from 1 to 45.
- The six numbers spill from
C2toC7, one next to each test focus in draw order: entry 27 is tested for round amounts, entry 19 for a missing description. - Set
F2to 5 and the pool holds only 5 entries; n is 6, so IF returns More items than entries instead of a draw that would silently leave the last test focus without an entry. After the draw, copyC2:C7and paste as values: there is no seed, so this draw can never be recreated.
Watch out: The mirror-image mistake is RANDARRAY(6, 1, 1, 45, TRUE). It looks right, six whole numbers from 1 to 45, but each cell is drawn on its own, and about 29% of draws contain a repeated number: one entry is tested twice for two foci, and another is never tested.
More on this example: why it works, 2 more pitfalls, 1 variation
Why it works
RANDARRAY never supplies the selected entry numbers directly; it only supplies the order. The numbers come from SEQUENCE, which lists every entry once, so taking the first n of a shuffle is a draw without replacement, and repeats are impossible by construction.
Do not use this construction when the selection must be reproducible for a reviewer, because RANDARRAY has no seed. The alternative is a helper column of random keys created once and frozen as values next to the entry list, then sorted by that column, which costs an extra column but leaves evidence of exactly how the sample was chosen.
More to watch out for
- A live draw recalculates when anyone types, so a later edit changes the selection after you wrote it in the working paper. Switch calculation to manual before the draw, press F9 once, and freeze.
- For a population of hundreds of thousands of journal lines, SEQUENCE and RANDARRAY build and sort that many values on every recalculation. Shuffle once into a frozen column instead, or draw a few numbers and check for repeats.
Variations
=SORT(TAKE(SORTBY(SEQUENCE(45),RANDARRAY(45)), 6))
=SORT(TAKE(SORTBY(SEQUENCE(45);RANDARRAY(45)); 6))
The bare draw, without LET or the safety check, sorted from low to high so you can work through the extract in order. Shorter, but the 45 and 6 are typed in and do not follow the sheet.
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| The same number appears twice | RANDARRAY(6, 1, 1, 45, TRUE) is used to draw 6 different lottery numbers, and sometimes a number appears twice. | Each cell is an independent draw. For different numbers, shuffle the full range with SORTBY(SEQUENCE(45), RANDARRAY(45)) and take the first 6, as in the Master example. |
| Yesterday's numbers are different today | The random numbers you analyzed yesterday are different today, and your notes no longer match the sheet. | Opening the file recalculated them. Once a draw is final, copy the spill range and paste it as values. |
| Decimals like 6.2817 instead of whole numbers | RANDARRAY(4, 3, 1, 10) is meant to give marks from 1 to 10 and shows values like 6.2817. | whole_number defaults to FALSE, so you get decimals. Add TRUE as the fifth argument. |
| Workbook slow on every edit | A model with RANDARRAY(100000, 10) has become slow on every edit. | A million volatile cells are redrawn, with everything that depends on them, on every change. Freeze the block as values once it has served its purpose, or set calculation to manual while you work. |
Used in combinations
- Random sample of journal lines with TAKE, SORTBY and RANDARRAYSelect n journal lines at random, never the same line twice: RANDARRAY gives every line a random key, SORTBY puts the lines in that order and TAKE keeps the first n.Excel 2024 or later (This combination needs Excel 2024 or later)