Excel - RANDARRAY Function



RANDARRAY Function

The RANDARRAY function is one of the exclusive functions introduced in the latest version of Excel 2021 or Excel 365. It returns an array comprising numbers between 0 and 1. It asks how many rows and columns are required to generate random floating or whole numbers quickly. For example, the RANDARRAY function can create an array of patient IDs between two numbers to get their sample and various random years. This function works efficiently with other functions like SORT, INDEX, UNIQUE, etc.

Compatibility

This prominent RANDARRAY function is compatible with the various versions of the MS Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel for iPad
  • Excel for iPhone
  • Excel for Android tablets
  • Excel for Android phones

Syntax

The syntax of the RANDARRAY function is as follows −

=RANDARRAY([rows],[columns],[min],[max],[integer]) 

Arguments

The description of the RANDARRAY function is as follows −

Argument Description Required / Optional
[rows] It specifies the number of rows to be retrieved. Optional
[columns] It specifies the number of columns to be retrieved. Optional
[min] It represents a minimum value from which a random number is generated in the final array. Optional
[max] It specifies the maximum value that can be generated in the final array. Optional
[integers] It contains Boolean values (True/False). If it equals True, then it will retrieve a whole number. Otherwise, it will retrieve only decimal numbers. Optional

Points to Remember

  • If you define the RANDARRAY() with no arguments, then the RANDARRAY() function will retrieve a decimal value of 0 and 1.
  • If the maximum arguments value is smaller than the minimum arguments value, then the RANDARRAY () function will return a #VALUE! Error.
  • By default, the RANDARRAY () will return an array of decimal values.

Examples of RANDARRAY Function

Practice the following examples to learn the use of the RANDARRAY function in Excel.

Example 1

The RANDARRAY function in Microsoft Excel generates an array of random numbers.

Solution

Suppose the user needs to generate the 6*4 array in the worksheet. To achieve this, enter the formula =RANDARRAY(6,4) in the B3 cell.

Excel RANDARRAY Function 1

Press the Enter tab, and the RANDARRAY() function will return the random floating numbers between 0 and 1.

Excel RANDARRAY Function 2

Example 2

Creating a 3*3 array with specified minimum and maximum values using the RANDARRAY function.

Solution

Step 1 − First, double-click on the B3 cell and type the formula =RANDARRAY(3,3,5,10) in the B3 cell.

Excel RANDARRAY Function 3

Step 2 − Therefore, a 3*5 array of decimal numbers is populated through this RANDARRAY function after setting the minimum and maximum values.

Excel RANDARRAY Function 4

Example 3

Create only random integer numbers in a 5*6 array using the RANDARRAY function in Excel

Solution

Step 1 − First, enter the formula "=RANDARRAY(5,6,1,7,TRUE)" in the B3 cell.

Excel RANDARRAY Function 5

Step 2 − After that, press the Enter tab to get the array with 5*6 dimension of the integers numbers.

Excel RANDARRAY Function 6

Explanation

=RANDARRAY(5,6,1,7,TRUE)
  • The first and second arguments denote the five rows and six columns to be generated in an array.
  • The third argument, 1, indicates the minimum integer value in the resulting array.
  • The fourth argument, 7, indicates the maximum value in the generated array.
  • The fifth argument, TRUE, specifies that only integer values are to be generated.

Example 4

Creating an array of random dates between defined dates using the RANDARRAY function.

Solution

Two dates are specified in the H2 and H3 cells. Enter the formula "=RANDARRAY(2,2,H2, H3,1)" in the G5 cell and press the Enter tab.

Excel RANDARRAY Function 7

Therefore, the RANDARRAY() function will return an array of 2*2 array.

Excel RANDARRAY Function 8

Now, change the formatting of the cells to the Date format.

Excel RANDARRAY Function 9

As you can notice in the screenshot, the arrays dates lie between two dates, which is defined in H2 and H3 cells.

Advertisements