0
0
ExcelHow-ToBeginner ยท 3 min read

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 rows and columns will return a single random decimal between 0 and 1.
  • For whole numbers, set whole_number to TRUE; otherwise, decimals are returned.
  • Using min greater than max causes an error.
  • Remember that RANDARRAY recalculates 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

ParameterDescriptionDefault
rowsNumber of rows in the array1
columnsNumber of columns in the array1
minMinimum random number0
maxMaximum random number1
whole_numberTRUE for whole numbers, FALSE for decimalsFALSE
โœ…

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.