Skip to content

MAKEARRAY

Builds an array of a size you choose, calling a LAMBDA with each row and column number to work out every value.

Syntax

=MAKEARRAY(, , )

LAMBDA and LET

Excel for Microsoft 365, Excel 2024 and later, and Excel for the web. Not available in Excel 2021 or earlier.

Try it

Edit the formula in A1 or change the inputs. The sheet recalculates as you type.

A1
A
B
C
D
E
F
1
1
2
3
4
2
2
4
6
8
3
3
6
9
12
4
5

A1 =MAKEARRAY(3,4,LAMBDA(r,c,r*c)) returns 1, 2, 3, 4; 2, 4, 6, 8; 3, 6, 9, 12

How MAKEARRAY works

MAKEARRAY creates a grid from nothing but a size and a rule. You say how many rows and columns you want, and give a LAMBDA that works out one cell from its position. Excel calls the LAMBDA for every cell and spills the result.

The arguments

  • rows and cols are the size of the grid.
  • lambda has two parameters. The first is the row number of the cell being calculated and the second is its column number. Both start at 1. The LAMBDA returns the value for that cell.

=MAKEARRAY(3,4,LAMBDA(r,c,r*c)) builds a three-row, four-column multiplication table. In the cell on row 2 and column 3, the LAMBDA receives r = 2 and c = 3, and returns 6.

Using the position to look things up

The row and column numbers can be fed to INDEX, so a grid can combine two lists. With prices down A2:A4 and quantities across B1:D1:

=MAKEARRAY(3,3,LAMBDA(r,c,INDEX(A2:A4,r)*INDEX(B1:D1,c)))

builds a revenue grid for every price and quantity. Put it in B2 and it sits neatly under the quantities and beside the prices. =A2:A4*B1:D1 returns the same grid in less typing, because Excel stretches a column against a row. MAKEARRAY is for when the calculation needs more than simple multiplication, such as an IF, a lookup or a formula that depends on the position.

Patterns that depend on position

The row and column numbers make it easy to draw patterns and special matrices:

  • Identity matrix. =MAKEARRAY(3,3,LAMBDA(r,c,IF(r=c,1,0))) puts 1 on the diagonal and 0 elsewhere.
  • Checkerboard. =MAKEARRAY(4,4,LAMBDA(r,c,MOD(r+c,2))) alternates 0 and 1.
  • Triangular tables. =MAKEARRAY(5,5,LAMBDA(r,c,IF(c<=r,r*c,""))) fills only the lower half.

MAKEARRAY or SEQUENCE

SEQUENCE is simpler when the values are evenly spaced numbers. Use MAKEARRAY when each cell needs its own calculation. SEQUENCE can often do the same job by working with two sequences, as in SEQUENCE(3)*SEQUENCE(1,3), and it is faster on big grids.

Rules

The LAMBDA must return a single value for each cell. Returning an array gives #CALC!. The number of rows or columns must be at least 1. The result spills, so #SPILL! means something is in the way.

See LAMBDA for how to write the function, and MAP to calculate from an existing array instead of from positions.

MAKEARRAY needs Microsoft 365, Excel 2024 or later, or Excel for the web.

Arguments

rows
How many rows the result has. It must be at least 1.
cols
How many columns the result has. It must be at least 1.
lambda
A LAMBDA with two parameters. It is called once for every cell and receives that cell's row number first and column number second, both counted from 1. It must return a single value, such as LAMBDA(r,c,r*c).

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

A multiplication table

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

Result: 1, 2, 3, 4; 2, 4, 6, 8; 3, 6, 9, 12

The LAMBDA is called twelve times. Each time r is the row number and c is the column number, and it returns their product.

A1
A
B
C
D
E
F
1
1
2
3
4
2
2
4
6
8
3
3
6
9
12
4
5

A1 =MAKEARRAY(3,4,LAMBDA(r,c,r*c)) returns 1, 2, 3, 4; 2, 4, 6, 8; 3, 6, 9, 12

Example 2

An identity matrix

A1 =MAKEARRAY(3,3,LAMBDA(r,c,IF(r=c,1,0)))

Result: 1, 0, 0; 0, 1, 0; 0, 0, 1

The IF puts a 1 where the row number equals the column number, which is the diagonal.

A1
A
B
C
D
E
F
1
1
0
0
2
0
1
0
3
0
0
1
4
5

A1 =MAKEARRAY(3,3,LAMBDA(r,c,IF(r=c,1,0))) returns 1, 0, 0; 0, 1, 0; 0, 0, 1

Example 3

Revenue grid from a list of prices and a list of quantities

B2 =MAKEARRAY(3,3,LAMBDA(r,c,INDEX(A2:A4,r)*INDEX(B1:D1,c)))

Result: 10, 50, 100; 20, 100, 200; 30, 150, 300

For each cell, INDEX picks the price for the row and the quantity for the column and multiplies them. The grid fills B2:D4, under the quantities and beside the prices.

B2
A
B
C
D
E
F
1
Unit price
1
5
10
2
10
10
50
100
3
20
20
100
200
4
30
30
150
300
5

B2 =MAKEARRAY(3,3,LAMBDA(r,c,INDEX(A2:A4,r)*INDEX(B1:D1,c))) returns 10, 50, 100; 20, 100, 200; 30, 150, 300

Example 4

A checkerboard pattern

A1 =MAKEARRAY(4,4,LAMBDA(r,c,MOD(r+c,2)))

Result: 0, 1, 0, 1; 1, 0, 1, 0; 0, 1, 0, 1; 1, 0, 1, 0

The sum of the row and column numbers is even on one set of squares and odd on the other. MOD turns that into 0 or 1.

A1
A
B
C
D
E
F
1
0
1
0
1
2
1
0
1
0
3
0
1
0
1
4
1
0
1
0
5

A1 =MAKEARRAY(4,4,LAMBDA(r,c,MOD(r+c,2))) returns 0, 1, 0, 1; 1, 0, 1, 0; 0, 1, 0, 1; 1, 0, 1, 0

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In F2, build a grid with 3 rows and 5 columns where each cell is the row number times 10, plus the column number (so the first row is 11, 12, 13, 14, 15).

Answer in F2.

F2
A
B
C
D
E
F
G
H
I
J
1
Unit price
10
20
50
2
4
3
6
4
8
5
6
7
8

Common mistakes

  • The first LAMBDA parameter is the row number and the second is the column number. Swap them and a grid that is not square comes out with the wrong values.
  • Rows and columns count from 1, not 0. In a LAMBDA that uses r-1 for an offset, check the first cell carefully.
  • The LAMBDA must return a single value. If it returns an array or a range, MAKEARRAY returns #CALC!.
  • A size of 0 or less is invalid. If the size comes from a cell, make sure it can not be 0.
  • For simple grids, SEQUENCE or plain array arithmetic is shorter. Use MAKEARRAY when the value depends on the position in a way those can't express.

Questions people ask

What does MAKEARRAY do in Excel?

It builds an array of a size you set. For each cell it calls a LAMBDA with the cell's row number and column number, and the LAMBDA returns the value.

What is the difference between MAKEARRAY and SEQUENCE?

SEQUENCE returns evenly spaced numbers. MAKEARRAY returns whatever your LAMBDA calculates from the row and column, including text, tests and lookups.

Do the row and column numbers start at 0 or 1?

At 1. The first cell is called with row 1 and column 1.

How do I build a grid that combines two lists?

Use INDEX with the row and column numbers: `=MAKEARRAY(3,3,LAMBDA(r,c,INDEX(A2:A4,r)*INDEX(B1:D1,c)))`. The row picks from the first list and the column from the second.

Does MAKEARRAY work in Excel 2021?

No. It is available in Microsoft 365, Excel 2024 and later, and Excel for the web. Earlier versions return `#NAME?`.

Learn MAKEARRAY in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.