How to Use RANDARRAY in Excel: Generate Random Arrays Easily
Use the
RANDARRAY function in Excel to generate an array of random numbers. You can specify the number of rows, columns, minimum and maximum values, and whether to generate whole numbers or decimals. This function updates automatically when the worksheet recalculates.Syntax
The RANDARRAY function syntax is:
=RANDARRAY([rows], [columns], [min], [max], [whole_number])
- rows (optional): Number of rows to fill with random numbers. Default is 1.
- columns (optional): Number of columns to fill. Default is 1.
- min (optional): Minimum value for the random numbers. Default is 0.
- max (optional): Maximum value for the random numbers. Default is 1.
- whole_number (optional): TRUE to generate whole numbers, FALSE for decimals. Default is FALSE.
excel
=RANDARRAY([rows], [columns], [min], [max], [whole_number])
Example
This example generates a 3-row by 4-column array of whole numbers between 10 and 50.
excel
=RANDARRAY(3, 4, 10, 50, TRUE)
Output
34 12 47 29
15 50 11 38
22 44 19 30
Common Pitfalls
- Not specifying
rowsandcolumnswill return a single random decimal between 0 and 1. - For whole numbers, set
whole_numberto TRUE; otherwise, decimals are returned. - Using
mingreater thanmaxcauses an error. - Remember that
RANDARRAYrecalculates on every worksheet change, so values will change unless you copy and paste as values.
excel
=RANDARRAY(2, 3, 50, 10, TRUE) // Wrong: min > max =RANDARRAY(2, 3, 10, 50, TRUE) // Correct
Quick Reference
| Parameter | Description | Default |
|---|---|---|
| rows | Number of rows in the array | 1 |
| columns | Number of columns in the array | 1 |
| min | Minimum random number | 0 |
| max | Maximum random number | 1 |
| whole_number | TRUE for whole numbers, FALSE for decimals | FALSE |
Key Takeaways
RANDARRAY creates arrays of random numbers with customizable size and range.
Specify TRUE for whole_number to get integers; otherwise, decimals are returned.
The function recalculates on every worksheet change, so values update automatically.
Ensure min is less than or equal to max to avoid errors.
Use optional parameters to control rows, columns, and number type.