The RANDARRAY function in Excel is a versatile tool designed to generate a dynamic array of random numbers. It provides users with the capability to customize the size of the array, the range of values, and whether the output should consist of whole numbers or decimals. This function can be particularly useful in simulations, statistical analyses, and any scenario requiring random number generation.
Syntax
RANDARRAY([rows], [columns], [min], [max], [integer])
- rows: Specifies the number of rows for the output array.
- columns: Specifies the number of columns for the output array.
- min: Sets the minimum value for the random numbers generated.
- max: Sets the maximum value for the random numbers generated.
- integer: A logical value (TRUE or FALSE) to determine whether the output should be whole numbers (TRUE) or decimals (FALSE).
Example #1
=RANDARRAY(3, 2)
This command generates a 3×2 array of random decimal numbers, each ranging from 0 to 1. For instance, the result could look like this: 0.67, 0.43
; 0.29, 0.89
; 0.52, 0.94
.
Example #2
=RANDARRAY(2, 2, 10, 20, TRUE)
This formula creates a 2×2 array of random whole numbers between 10 and 20. An example output could be: 15, 12
; 18, 11
.
Example #3
=RANDARRAY(1, 3, 1, 100, FALSE)
This function yields a single row array containing three random decimal values ranging from 1 to 100. For instance, the output may be: 23.67, 45.34, 92.11
.
Error handling
- VALUE!: This error occurs if non-numeric values are provided for the rows, columns, min, or max parameters.
- NUM!: This error arises when the min value is greater than the max value.
- SPILL!: This indicates that the output array is too large to fit into the available cells.