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.