RANDARRAY function
RANDARRAY fills a whole grid with random numbers in one formula, for test data or random sampling. It recalculates constantly like RAND, and the block of results spills into neighboring cells.
Example
Read it as a sentence: make a list of 5 random numbers and count its rows, which gives 5.
Syntax
RANDARRAY([rows], [columns], [min], [max], [whole_number])
Arguments in [square brackets] are optional.
-
rows(optional) - How many rows. Default 1.
-
columns(optional) - How many 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: A block of random numbers that spills.
One RANDARRAY formula can fill more than one cell. When the result has several values, they spill into the cells below or to the right of the formula.
RANDARRAY is volatile: Excel works it out again every time anything in the workbook changes.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=ROWS(RANDARRAY(3,2))*10+COLUMNS(RANDARRAY(3,2)) | 32 | Size 3x2 counted |
=LET(x,RANDARRAY(),AND(x>=0,x<1)) | TRUE | No args single value in [0,1) |
=LET(a,RANDARRAY(20,1,1,3,TRUE),AND(MIN(a)>=1,MAX(a)<=3,SUM(a-INT(a))=0)) | TRUE | Whole numbers in range |
=RANDARRAY(1,2,4,4) | 4 | Min = max |
=RANDARRAY(2,2) | 0.921561027 | Spill raw (volatile) |
=RANDARRAY(2,2,5,1) | #VALUE! | Min > max |
=RANDARRAY(0) | #CALC! | Rows 0 |
=RANDARRAY(-1) | #VALUE! | Rows -1 |
Watch out for
- Recalculates constantly, like RAND.
- With whole_number TRUE, min and max are both inclusive.
Where it works
- Excel
- RANDARRAY arrived in Excel 2021. Older versions do not have it. Excel 2021 and later, plus 365.
- Google Sheets
- Same name, same behaviour for everyday use. Sheets has RANDARRAY with the same arguments.
Part of Math and trig functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .