RANDARRAY function
Returns a spilled array of random numbers with the size, range and type (decimal or whole) you choose.
Available in Microsoft 365, Excel 2021 and later, Excel for the web
Excel 2021 and laterDifferent in Google Sheets
Syntax
RANDARRAY([rows], [columns], [min], [max], [whole_number])| Argument | What it means | |
|---|---|---|
rows | Optional | Number of rows to return. Default 1. |
columns | Optional | Number of columns. Default 1. |
min | Optional | Smallest value. Default 0. |
max | Optional | Largest value. Default 1. |
whole_number | Optional | TRUE for integers, FALSE (default) for decimals. |
Returns: An array of random numbers that spills into neighbouring cells.
How RANDARRAY works
RANDARRAY creates a whole block of random numbers with one formula. =RANDARRAY(5, 3) fills 5 rows by 3 columns with decimals between 0 and 1; add min, max and TRUE for whole numbers, e.g. =RANDARRAY(10, 1, 1, 6, TRUE) for ten dice rolls. It replaces dragging RAND or RANDBETWEEN formulas across a range.
As a dynamic-array function its result spills into the cells below and to the right, so they must be empty (otherwise you see #SPILL!). Like RAND it is volatile and recalculates whenever the sheet changes. A neat trick is to use it as a sort key: =SORTBY(list, RANDARRAY(ROWS(list))) returns a shuffled copy of a list. With decimals, the max value itself is never returned; with whole numbers both min and max are possible.
Examples
1A 3 × 2 block of random decimals
| A | B | |
|---|---|---|
| 1 | 0.2841 | 0.9035 |
| 2 | 0.5517 | 0.1209 |
| 3 | 0.7763 | 0.4380 |
Six decimals between 0 and 1, shown with 4 decimals. Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.
2Simulate ten dice rolls
| A | |
|---|---|
| 1 | 4 |
| 2 | 1 |
| 3 | 6 |
| 4 | 3 |
| 5 | 3 |
| 6 | 5 |
| 7 | 2 |
| 8 | 6 |
| 9 | 1 |
| 10 | 4 |
Whole numbers from 1 to 6 in a column. Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.
3Shuffle a list of names
| A | B | C | |
|---|---|---|---|
| 1 | Employee | ||
| 2 | Ana | Dev | |
| 3 | Ben | Ana | |
| 4 | Chloe | Ema | |
| 5 | Dev | Chloe | |
| 6 | Ema | Ben |
Each name gets a random sort key and SORTBY orders by it, giving a random running order for presentations. Because the function recalculates whenever the sheet changes, your result will differ; the value shown is only an illustration.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#SPILL! | Cells in the spill area are not empty. | Clear the cells below/right of the formula. |
#VALUE! | min is larger than max, or rows/columns are 0 or negative. | Check the arguments. |
#NAME? | Excel 2019 or older. | Use RAND/RANDBETWEEN filled across the range. |
Tips
- Freeze the numbers with Copy > Paste Values.
- Random test data for sales between 500 and 2,000:
=RANDARRAY(20, 1, 500, 2000, TRUE).
Google Sheets
Google Sheets' RANDARRAY(rows, columns) only returns decimals between 0 and 1; there are no min, max or whole_number arguments, so scale with ROUND(min + RANDARRAY(r, c) * (max - min)).
RANDARRAY in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Danish | SLUMPMATRIX |
| Dutch | ASELECT.MATRIX |
| Finnish | SATUNN.MATRIISI |
| German | ZUFALLSMATRIX |
| Hungarian | VÉLETLENTÖMB |
| Italian | MATR.CASUALE |
| Norwegian (Bokmål) | TILFELDIGMATRISE |
| Polish | LOSOWA.TABLICA |
| Portuguese (Brazil) | MATRIZALEATÓRIA |
| Portuguese (Portugal) | MATRIZALEATÓRIA |
| Spanish | MATRIZALEAT |
| Swedish | SLUMPMATRIS |
| Turkish | RASGDİZİ |