Applies ToExcel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web

Returns a calculated array of a specified row and column size, by applying a LAMBDA.

Syntax

=MAKEARRAY(rows, cols, lambda(row, col))

The MAKEARRAY function syntax has the following arguments and parameters:

  • rows      The number of rows in the array. Must be greater than zero.

  • cols      The number of columns in the array. Must be greater than zero.

  • lambda       A LAMBDA that is called to create the array. The LAMBDA takes two parameters: 

    • row      The row index of the array.

    • col      The column index of the array.

Errors

Providing an invalid LAMBDA function or an incorrect number of parameters returns a #VALUE! error called "Incorrect Parameters".

Setting a row or col argument to a value < 1 or to a non-number returns a #VALUE! error.

Examples

Example 1: Create a 2D array representing a simple multiplication table

Copy the following formula into cell C2:

=MAKEARRAY(3, 3, LAMBDA(r,c, r*c))

First MAKEARRAY function example

Example 2: Create a random list of values

Enter the sample data into cells D1:E3, and then copy the formula into cell D4:

=MAKEARRAY(D2,E2,LAMBDA(row,col,CHOOSE(RANDBETWEEN(1,3),"Red","Blue","Green")))

Second MAKEARRAY Function example

See Also

LAMBDA function 

MAP function

REDUCE function

SCAN function

BYCOL function

BYROW function

ISOMITTED function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.