How to Use the MAKEARRAY Function in Google Sheets | Automatically Generate an Array or Table of a Specified Size
What Is the MAKEARRAY Function?
The MAKEARRAY function generates a 2D array (table) of a specified number of rows and columns from scratch. Using a LAMBDA function, you can calculate and determine the value of each cell based on its row number and column number. This is useful for multiplication tables, calendar grids, and generating dummy data.
Syntax
=MAKEARRAY(rows, columns, LAMBDA(row_index, col_index, formula_expression))
- rows: A positive integer specifying the number of rows in the generated array.
- columns: A positive integer specifying the number of columns in the generated array.
- LAMBDA(row_index, col_index, formula_expression):
- row_index: Automatically receives the current row number (
1torows). - col_index: Automatically receives the current column number (
1tocolumns). - formula_expression: The formula that calculates the value to output in each cell.
- row_index: Automatically receives the current row number (
Example
Here is an example of automatically generating a 5-row × 5-column multiplication table starting at cell A1.
| Row | Column A (Formula & Col 1) | Column B (Col 2) | Column C (Col 3) | Column D (Col 4) | Column E (Col 5) |
|---|---|---|---|---|---|
| 1 | =MAKEARRAY(5, 5, LAMBDA(r, c, r * c)) → 1 |
2 | 3 | 4 | 5 |
| 2 | 2 | 4 | 6 | 8 | 10 |
| 3 | 3 | 6 | 9 | 12 | 15 |
| 4 | 4 | 8 | 12 | 16 | 20 |
| 5 | 5 | 10 | 15 | 20 | 25 |
Common Errors and Notes
#VALUE!Error: Specifying0, a negative number, or a text string for the first argument (rows) or second argument (columns) causes a#VALUE!error. Always specify a number of1or greater.#REF!Error (Obstacle in Spill Range): If any cell within the specifiedrows × columnsrange already contains data or a formula, the array cannot spill and returns#REF!.- Avoid Oversized Arrays: Specifying a massive size such as thousands of rows by thousands of columns can slow down sheet recalculation or trigger cell limit errors. Specify only the size you need.
Frequently Asked Questions
Q. How do I get the row and column numbers when creating a sequence or matrix with MAKEARRAY?
A. LAMBDA automatically receives the row number (an integer starting at 1) as its first parameter and the column number (an integer starting at 1) as its second parameter, so you can use them directly in your formula.
Q. Can I use MAKEARRAY to create a table of random numbers?
A. Yes. For example, writing =MAKEARRAY(5, 3, LAMBDA(r, c, RANDBETWEEN(1, 100))) instantly generates a 5-row by 3-column table of random integers.