Returns an array of specified dimensions with values calculated by application of a LAMBDA function. Learn more
The MAKEARRAY function in Google Sheets allows you to create a new array with the specified number of rows and columns. This function can be used to generate a new array of data based on existing data or to create a blank array for data entry. Additionally, it can accept a LAMBDA function that generates the values to be placed in each cell of the array.
The syntax of the MAKEARRAY function is as follows:
=MAKEARRAY(rows, columns, LAMBDA)
rows represents the number of rows in the array. columns represents the number of columns in the array. LAMBDA is an optional parameter that specifies a function to generate the values to be placed in each cell of the array.
If the LAMBDA parameter is not specified, the MAKEARRAY function creates a new blank array with the specified number of rows and columns. If the LAMBDA parameter is specified, the function generates the values for each cell of the array using the specified LAMBDA function.
The LAMBDA function used in the MAKEARRAY function takes two arguments: row and column. These arguments represent the current row and column index of the cell being populated. The LAMBDA function must return a value that will be placed in the corresponding cell of the array.
For example, suppose you want to create a new 3x3 array that contains the square of each number from 1 to 9. You can use the following formula:
=MAKEARRAY(3, 3, LAMBDA(row, col, row * col))
This formula creates a 3x3 array and uses the LAMBDA function to populate each cell of the array with the product of its row and column index.