RANDARRAY returns a block of random numbers from one formula. It is RAND and RANDBETWEEN with a size: you say how many rows and columns, the range, and whether you want whole numbers.
The arguments
- rows and columns set the size of the result. Both default to 1, so
=RANDARRAY() is the same as RAND. - min and max set the range. The defaults are 0 and 1.
- whole_number is
FALSE for decimals (the default) or TRUE for whole numbers. With TRUE, both ends of the range can be returned: =RANDARRAY(10,1,1,6,TRUE) is ten dice rolls.
It recalculates constantly
RANDARRAY is volatile. It produces new numbers every time the worksheet recalculates, which means after nearly any edit anywhere in the workbook, and each time you press F9. That is the point when you want a fresh draw, and a problem when you want to keep one. To freeze a result, copy the spilled cells and use Paste Special > Values.
Because the numbers are always changing, any figure built from RANDARRAY on its own changes too. When you test a formula that uses it, check things that stay true on every draw: the size of the result, that every value falls in the range, or that a shuffled list still adds up to the same total. The examples below do exactly that.
Shuffling and random picks
The most useful job for RANDARRAY is putting a list in random order. Sort the list by a column of random numbers:
=SORTBY(A2:A7,RANDARRAY(ROWS(A2:A7)))
Every recalculation gives a new order, but the list always contains the same items. Wrap it in TAKE to pick random winners: =TAKE(SORTBY(A2:A20,RANDARRAY(ROWS(A2:A20))),3) returns three different names. RANDBETWEEN can return the same number twice. A shuffle can't.
Test data
For quick sample data, use =RANDARRAY(20,1,500,2000,TRUE) for twenty whole-number amounts, or =RANDARRAY(12,1,0.02,0.08) for twelve rates between 2% and 8%.
Spilling
The result spills into the cells below and to the right of the formula. If something occupies those cells, you get #SPILL!. See FILTER for how spill ranges work and how the # operator reads one.
RANDARRAY, RAND and RANDBETWEEN
RAND returns one decimal and RANDBETWEEN one whole number, so filling a block needs the fill handle. RANDARRAY needs one formula. Use RANDBETWEEN for a single value, and RANDARRAY for a block. None of them is suitable for anything that must be repeatable or secure: you can't set a seed in Excel.