RANDARRAY function
The RANDARRAY function in Excel generates an array of random numbers between 0 (inclusive) and 1 (exclusive) or within a specified range. This function is available in Excel 365, Excel 2021, and later versions that support dynamic arrays.
Syntax
=RANDARRAY([rows], [columns], [min], [max], [integer])
Parameters
- rows (optional): The number of rows in the array. Default is
1. - columns (optional): The number of columns in the array. Default is
1. - min (optional): The minimum value for the random numbers. Default is
0. - max (optional): The maximum value for the random numbers. Default is
1. - integer (optional): Whether to generate integers (
TRUE) or decimals (FALSE). Default isFALSE.
Key Features
- Dynamic Array Function: Automatically spills values into adjacent cells based on the specified rows and columns.
- Flexible Range: Allows custom ranges for random number generation.
- Integer Option: Can generate whole numbers by setting the
integerargument toTRUE.
Examples
- Generate a 3×3 array of random decimals between 0 and 1:
=RANDARRAY(3, 3) - Generate a 5×2 array of random integers between 10 and 50:
=RANDARRAY(5, 2, 10, 50, TRUE) - Generate a single random decimal number:
=RANDARRAY() - Generate a 4×4 array of random numbers between -5 and 5:
=RANDARRAY(4, 4, -5, 5)
Tips
- Use
RANDARRAYwhen you need multiple random numbers in one formula. - If the results should not change, copy the array and paste it as values.
- Combine
RANDARRAYwith other functions for advanced scenarios, such as simulating data or random sampling.