Skip to content

EXPAND

Grows an array to a size you choose, filling the new cells with #N/A or a value you pick.

Syntax

=EXPAND(, , , )

Dynamic arrays

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 D2 or change the inputs. The sheet recalculates as you type.

D2
A
B
C
D
E
F
G
H
1
Item
Qty
2
Gloves
40
Gloves
40
#N/A
3
Tape
25
Tape
25
#N/A
4
#N/A
#N/A
#N/A
5
#N/A
#N/A
#N/A
6
7

D2 =EXPAND(A2:B3,4,3) returns Gloves, 40, #N/A; Tape, 25, #N/A; #N/A, #N/A, #N/A; #N/A, #N/A, #N/A

How EXPAND works

EXPAND makes an array bigger. It keeps your values where they are and adds rows and columns to reach the size you ask for, filling the new cells with a value you choose. It is a small function, and it solves one specific problem: getting arrays to the same shape.

The arguments

  • array is what you start with.
  • rows is the total height you want, not the number of rows to add. A 2-row array expanded to 4 rows gets two new rows.
  • columns is the total width, in the same way. Leave it out to keep the original width.
  • pad_with is the fill. The default is #N/A, which makes it obvious that the cell was added. Use 0 for numbers or "" for empty-looking cells.

=EXPAND(A2:B3,4,3,0) turns a 2-by-2 block into a 4-by-3 block and fills the new cells with zeros.

You can only grow, not shrink

If the size you ask for is smaller than the array, EXPAND returns #VALUE!. To make an array smaller, use TAKE or DROP. If you aren't sure whether the array is smaller than the target, wrap the target in MAX: EXPAND(A2:B3,MAX(4,ROWS(A2:B3))).

Why you need it

The stacking functions pad mismatched arrays with #N/A by themselves, but only with that value, and you can't choose it. EXPAND lets you pad an array before you stack it, with the fill you want:

=VSTACK(A2:B3,EXPAND(D2:D3,,2,""))

Here the second block has one column and the first has two. EXPAND widens it to two columns with an empty-text fill, so the stacked result has no #N/A in it.

Matching the size of another block

To make one array the same size as another, take the dimensions from the other: =EXPAND(A2:B3,ROWS(D2:E6),COLUMNS(D2:E6),0) pads a small table to the size of a bigger one with zeros. That is useful before adding two tables cell by cell, because arithmetic on arrays of different sizes produces #N/A in the extra cells.

Padding a grid for display

EXPAND is also an easy way to draw a fixed-size grid, such as a template with 10 rows where only the first few have data: =EXPAND(FILTER(A2:B20,A2:A20<>""),10,,""). (If FILTER returns more than 10 rows, EXPAND returns #VALUE!, so check the sizes.)

Notes

The result spills down and to the right. If the cells it needs aren't empty, you get #SPILL!. See FILTER for spill ranges and the # operator.

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

Arguments

array
The range or array to enlarge.
rows
The number of rows in the result. It must be at least the number of rows in array, or EXPAND returns #VALUE!. To keep the same number of rows, give ROWS(array) or leave the argument empty.
columnsoptional
The number of columns in the result. It must be at least the width of array. If you leave it out, the width stays the same.
pad_withoptional
What to put in the new cells. The default is #N/A. Use 0, "" or any text.

Examples

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

Example 1

Grow a 2 by 2 table to 4 by 3

D2 =EXPAND(A2:B3,4,3)

Result: Gloves, 40, #N/A; Tape, 25, #N/A; #N/A, #N/A, #N/A; #N/A, #N/A, #N/A

The two original rows keep their values. The new cells hold the default fill, #N/A.

D2
A
B
C
D
E
F
G
H
1
Item
Qty
2
Gloves
40
Gloves
40
#N/A
3
Tape
25
Tape
25
#N/A
4
#N/A
#N/A
#N/A
5
#N/A
#N/A
#N/A
6
7

D2 =EXPAND(A2:B3,4,3) returns Gloves, 40, #N/A; Tape, 25, #N/A; #N/A, #N/A, #N/A; #N/A, #N/A, #N/A

Example 2

Fill the new cells with zeros

D2 =EXPAND(A2:B3,4,3,0)

Result: Gloves, 40, 0; Tape, 25, 0; 0, 0, 0; 0, 0, 0

The fourth argument replaces #N/A with 0 in every added cell.

D2
A
B
C
D
E
F
G
H
1
Item
Qty
2
Gloves
40
Gloves
40
0
3
Tape
25
Tape
25
0
4
0
0
0
5
0
0
0
6
7

D2 =EXPAND(A2:B3,4,3,0) returns Gloves, 40, 0; Tape, 25, 0; 0, 0, 0; 0, 0, 0

Example 3

Add rows only

D2 =EXPAND(A2:B3,4,,"-")

Result: Gloves, 40; Tape, 25; -, -; -, -

The empty columns argument keeps the width at two, so only rows are added.

D2
A
B
C
D
E
F
G
H
1
Item
Qty
2
Gloves
40
Gloves
40
3
Tape
25
Tape
25
4
-
-
5
-
-
6
7

D2 =EXPAND(A2:B3,4,,"-") returns Gloves, 40; Tape, 25; -, -; -, -

Example 4

Widen a block before stacking it

D2 =VSTACK(A2:B3,EXPAND(A5:A6,,2,""))

Result: Gloves, 40; Tape, 25; Wrap, ; Labels,

A5:A6 is one column wide. EXPAND makes it two wide with empty text, so VSTACK has nothing to pad with #N/A.

D2
A
B
C
D
E
F
G
H
1
Item
Qty
2
Gloves
40
Gloves
40
3
Tape
25
Tape
25
4
Wrap
5
Wrap
Labels
6
Labels
7
8

D2 =VSTACK(A2:B3,EXPAND(A5:A6,,2,"")) returns Gloves, 40; Tape, 25; Wrap, ; Labels,

Your turn.

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

Task 1 of 2

In H2, expand the tool table A2:B3 to 5 rows and 2 columns, filling the new cells with 0.

Answer in H2.

H2
A
B
C
D
E
F
G
H
I
J
1
Tool
Count
Aisle
Bin
Slot
2
Drill
6
A
B1
S1
3
Saw
4
A
B2
S2
4
B
B3
S3
5
B
B4
S4
6
7
8
9
10
11
12
13
14
15
16
17
18

Common mistakes

  • rows and columns are the final size, not the number to add. To add two rows to a 3-row array, ask for 5.
  • Asking for fewer rows or columns than the array has returns #VALUE!. EXPAND can only grow an array. Use TAKE or DROP to shrink.
  • The default fill is #N/A, which spreads through any total that includes the new cells. Set pad_with to 0 or "" if the result will be added up.
  • #SPILL! means the cells the larger array needs are not empty.
  • The new cells are values, not blanks. "" looks empty but still counts as text, so COUNTA counts it.

Questions people ask

What does EXPAND do in Excel?

It makes an array larger by adding rows and columns to the size you ask for, and fills them with #N/A or a value you choose. The original values stay where they are.

Why does EXPAND return #VALUE!?

The size you asked for is smaller than the array. EXPAND can only add rows and columns. To make an array smaller, use TAKE or DROP.

How do I pad an array with zeros instead of #N/A?

Use the fourth argument: `=EXPAND(A2:B3,4,3,0)`.

When is EXPAND useful?

When you need two arrays to be the same size, such as before stacking them or adding them together, and you want to decide what goes in the extra cells.

Does EXPAND 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 EXPAND in a real sheet.

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