
The `RANDARRAY` function in Excel is used to generate an array of random numbers. It has several optional arguments that allow you to customize the generated numbers. Here’s how to use it:
Basic Syntax
=RANDARRAY([rows], [columns], [min], [max], [integer])
Arguments:
- rows (optional): The number of rows of random numbers to return. If omitted, it defaults to 1.
- columns (optional): The number of columns of random numbers to return. If omitted, it defaults to 1.
- min (optional): The minimum number for the range of random numbers. If omitted, it defaults to 0.
- max (optional): The maximum number for the range of random numbers. If omitted, it defaults to 1.
- integer (optional): A boolean (TRUE or FALSE) indicating whether you want whole numbers (TRUE) or decimals (FALSE). If omitted, it defaults to FALSE.
Examples
=RANDARRAY()
- Generate a Single Random Number (default settings):
This returns a single random decimal number between 0 and 1.
=RANDARRAY(3, 4)
- Generate a 3×4 Array of Random Decimal Numbers:
This generates three rows and four columns of random decimal numbers between 0 and 1.
=RANDARRAY(5, 2, 1, 100, TRUE)
- Generate Random Integers Between 1 and 100:
This creates a 5×2 array of whole numbers between 1 and 100.
=RANDARRAY(4, 1, 50, 100)
- Generate Random Decimal Numbers Between 50 and 100:
This generates a 4×1 array of random decimal numbers between 50 and 100.
Notes
- The `RANDARRAY` function is available in Excel 365 and Excel 2019 or later.
- The numbers generated are recalculated each time the worksheet is recalculated, which can sometimes affect performance in large worksheets.
- If you want to freeze the generated numbers, copy them and paste them as values using Excel’s “Paste Special” feature.