Skip to content

VSTACK

Stacks ranges or arrays on top of each other into one array. Narrower arrays are padded with #N/A.

Syntax

=VSTACK(, [array2], …)

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

G2
A
B
C
D
E
F
G
H
I
1
Product
North
Product
South
2
Desk lamp
12
Desk lamp
9
Desk lamp
12
3
Monitor arm
8
Webcam
14
Monitor arm
8
4
USB-C hub
20
Desk lamp
9
5
Webcam
14
6
USB-C hub
20
7
8

G2 =VSTACK(A2:B3,D2:E4) returns Desk lamp, 12; Monitor arm, 8; Desk lamp, 9; Webcam, 14; USB-C hub, 20

How VSTACK works

VSTACK appends one range to another with a formula. Give it two or more ranges and it returns a single array with the first on top and each later one below. It replaces the copy-and-paste routine you used to use to combine monthly sheets or regional lists, and it stays up to date.

The arguments

Only one argument is required, and you can add many more. Each array can be a range, an array constant such as {"Product","Units"}, or the result of another formula. =VSTACK(A2:B3,D2:E4) returns the two rows of the first block followed by the three rows of the second: five rows in all.

When the widths differ

The result is as wide as the widest array. A narrower array is padded on the right with #N/A. If the first block has two columns and the second has three, the first block's rows get a #N/A in column three. To show blanks instead, wrap the formula in IFNA: =IFNA(VSTACK(A2:B3,G2:I3),"").

Adding a header

Most real use includes a header row. Add one as an array constant at the top: =VSTACK({"Product","Units"},A2:B3,D2:E4). Or keep the header from the first range by including it: =VSTACK(A1:B3,D2:E4).

Stacking, then working with the result

VSTACK is often the first step of a bigger formula. A single formula can consolidate several blocks and then filter, sort or total them:

  • =SORT(VSTACK(A2:B3,D2:E4),2,-1) returns the combined list ranked by its second column.
  • =SUM(VSTACK(B2:B3,E2:E4)) totals non-adjacent ranges.
  • =UNIQUE(VSTACK(A2:A3,D2:D4)) lists every product that appears in either block.

For ranges on different sheets, VSTACK combines them in the same way. Use VSTACK(Jan!A2:B20,Feb!A2:B20) in Excel. The exercises here use a single sheet.

VSTACK, HSTACK and TOCOL

HSTACK joins arrays side by side, which is the same idea along the other axis. TOCOL turns a whole block into one column. VSTACK keeps the shape of each block, TOCOL flattens everything.

Notes

Blank cells inside a range come back as 0, not as blanks. The result is a spilled array: if the cells it needs aren't empty you get #SPILL!. The # operator after the anchor cell refers to the whole result, as in =ROWS(G2#). See FILTER for details.

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

Arguments

array1
The first range or array. It sits at the top of the result.
array2, …optional
More ranges or arrays, each placed below the one before. They can come from different places in the workbook and can be the results of other formulas.

Examples

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

Example 1

Combine two lists

G2 =VSTACK(A2:B3,D2:E4)

Result: Desk lamp, 12; Monitor arm, 8; Desk lamp, 9; Webcam, 14; USB-C hub, 20

The two North rows come first, followed by the three South rows. The result is five rows by two columns.

G2
A
B
C
D
E
F
G
H
I
1
Product
North
Product
South
2
Desk lamp
12
Desk lamp
9
Desk lamp
12
3
Monitor arm
8
Webcam
14
Monitor arm
8
4
USB-C hub
20
Desk lamp
9
5
Webcam
14
6
USB-C hub
20
7
8

G2 =VSTACK(A2:B3,D2:E4) returns Desk lamp, 12; Monitor arm, 8; Desk lamp, 9; Webcam, 14; USB-C hub, 20

Example 2

Add a header row on top

G2 =VSTACK({"Product","Units"},A2:B3,D2:E4)

Result: Product, Units; Desk lamp, 12; Monitor arm, 8; Desk lamp, 9; Webcam, 14; USB-C hub, 20

An array constant works like any other array, so you can place a header above the data.

G2
A
B
C
D
E
F
G
H
I
1
Product
North
Product
South
2
Desk lamp
12
Desk lamp
9
Product
Units
3
Monitor arm
8
Webcam
14
Desk lamp
12
4
USB-C hub
20
Monitor arm
8
5
Desk lamp
9
6
Webcam
14
7
USB-C hub
20
8

G2 =VSTACK({"Product","Units"},A2:B3,D2:E4) returns Product, Units; Desk lamp, 12; Monitor arm, 8; Desk lamp, 9; Webcam, 14; USB-C hub, 20

Example 3

Different widths are padded with #N/A

A5 =VSTACK(A2:B3,D2:F3)

Result: Desk lamp, 12, #N/A; Monitor arm, 8, #N/A; Webcam, 14, 2; USB-C hub, 20, 1

The first block has two columns and the second has three, so the first block's rows are padded with #N/A. Wrap the formula in IFNA to replace them.

A5
A
B
C
D
E
F
G
H
I
1
Product
Units
Product
Units
Returns
2
Desk lamp
12
Webcam
14
2
3
Monitor arm
8
USB-C hub
20
1
4
5
Desk lamp
12
#N/A
6
Monitor arm
8
#N/A

A5 =VSTACK(A2:B3,D2:F3) returns Desk lamp, 12, #N/A; Monitor arm, 8, #N/A; Webcam, 14, 2; USB-C hub, 20, 1

Example 4

Total across two separate ranges

G2 =SUM(VSTACK(B2:B3,E2:E4))

Result: 63

12 + 8 + 9 + 14 + 20. SUM takes the stacked array as one list of numbers.

G2
A
B
C
D
E
F
G
H
I
1
Product
North
Product
South
2
Desk lamp
12
Desk lamp
9
63
3
Monitor arm
8
Webcam
14
4
USB-C hub
20
5
6
7
8

G2 =SUM(VSTACK(B2:B3,E2:E4)) returns 63

Example 5

A combined list of distinct products

G2 =UNIQUE(VSTACK(A2:A3,D2:D4))

Result: Desk lamp; Monitor arm; Webcam; USB-C hub

Desk lamp appears in both lists but only once in the result.

G2
A
B
C
D
E
F
G
H
I
1
Product
North
Product
South
2
Desk lamp
12
Desk lamp
9
Desk lamp
3
Monitor arm
8
Webcam
14
Monitor arm
4
USB-C hub
20
Webcam
5
USB-C hub
6
7
8

G2 =UNIQUE(VSTACK(A2:A3,D2:D4)) returns Desk lamp; Monitor arm; Webcam; USB-C hub

Your turn.

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

Task 1 of 2

In G2, combine the two lists into one, with the header from the first list on top.

Answer in G2.

G2
A
B
C
D
E
F
G
H
I
J
1
Expense
Q1
Expense
Q2
2
Rent
3,000
Rent
3,000
3
Power
450
Power
520
4
Cleaning
220
Cleaning
220
5
Repairs
640
6
7
8
9
10
11
12

Common mistakes

  • Arrays of different widths do not raise an error. The narrower one is padded with #N/A, which can break a SUM or look like a lookup failure. Use IFNA(VSTACK(...),""), or make the widths match first with EXPAND.
  • Column order is not matched by header name. VSTACK stacks columns by position, so if one source has Product, Units and another has Units, Product, the data lines up wrongly. Check the column order of every block.
  • Include the header of only one block. Selecting A1:B3 and D1:E4 repeats the header text in the middle of the result.
  • Blank cells inside a source come back as 0, not as empty cells.
  • #SPILL! means the cells the result needs are not empty. Clear them or move the formula.

Questions people ask

How do I combine two ranges into one list in Excel?

Use `=VSTACK(A2:B10,D2:E15)`. The second range is placed directly below the first, and the result grows as either range does.

Why does VSTACK show #N/A?

The arrays have different numbers of columns, and VSTACK pads the narrower one with `#N/A`. Wrap the formula in `IFNA(...,"")`, or use EXPAND to widen the narrower array first.

Can VSTACK combine ranges from different sheets?

Yes. Give it a range from each sheet, such as `=VSTACK(Jan!A2:B20,Feb!A2:B20,Mar!A2:B20)`. To pick up new rows added later, make each range generously long and filter out the blanks.

How do I add a header row to a formula result?

Stack an array constant on top: `=VSTACK({"Product","Units"},A2:B10)`. Text goes in quotes, and commas separate columns.

What is the difference between VSTACK and HSTACK?

VSTACK puts arrays on top of each other, and HSTACK puts them side by side.

Learn VSTACK in a real sheet.

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