The RANDARRAY function returns an array of random numbers between a specified minimum and maximum, and you can decide whether to return whole numbers of decimal values. It’s super useful for simulations and modelling.
The syntax is:
=RANDARRAY([rows],[columns],[min],[max],[integer])
rows is optional. Here you can specify the number of rows to be returned.
columns is optional and allows you to specify the number of columns to be returned. min is optional allowing you to specify a minimum random value. max is optional allowing you to specify a maximum random value. integer is optional, choose TRUE for an integer and FALSE for a decimal.If you omit all arguments, RANDARRAY will return a single value between 0 and 1
Note: The RANDARRAY function is part of the new Excel Dynamic Arrays family. At the time of writing, Dynamic Arrays are only available in Office 365 and are currently in beta on the Insiders channel. Excel 2019 will not have the Dynamic Array functions.
Excel RANDARRAY Function Examples
We can use the RANDARRAY function to return a list of 5 random numbers between 0 and 1, as shown in the image below. Notice how the formula is in cell B14 and the results ‘spill’ into the cells below:
The spilling of the array is possible with the new dynamic array formula functionality.
In the next example we use RANDARRAY to return a 3 row x 2 column array. Again it spills the results:
If you prefer whole numbers you can use TRUE in the integer argument, as shown below. You'll also need to specify a min and max otherwise you'll end up with zeros and ones.
If you want to return a row of random numbers you can omit the row argument, as shown below:
And if you prefer your random numbers sorted you can wrap it in the SORT function:
We can get creative with the new dynamic array functions to generate a list of randomly sorted numbers between 1 and 10, as shown below:
The SEQUENCE function simply returns an array of values from 1 to 10. The SORTBY function then uses 10 random values produced by RANDARRAY to sort them.
Download the Workbook
Enter your email address below to download the sample workbook.
Related Tutorials
Excel FILTER Function | Filter cells based on criteria. |
Excel SEQUENCE Function | Returns list of sequential numbers that increment as specified. |
Excel SORT Function | Sort cells or arrays in ascending or descending order. |
Excel SORTBY Function | Sort cells or arrays based on criteria. |
Excel UNIQUE Function | Extract a unique or distinct list from a range or array. |