VSTACK

Short answer

Combine entity tabs into one table

VSTACK(array1, [array2], ...)
Excel version
2024+
Also searched as
stack ranges, append tabs, consolidate sheets, combine tables formula, hstack, actuals and forecast in one range

What it returns

VSTACK appends arrays one under another and returns the result as a single spilled array. Give it the UK ledger, the US ledger and the Germany ledger, each a Table with the same columns, and it returns one block with every row from all three.

The output is as tall as the inputs combined and as wide as the widest input. If one input is narrower, VSTACK pads the missing cells with #N/A.

HSTACK is the same idea turned sideways. It places arrays next to each other, left to right, and pads short ones with #N/A at the bottom. Its syntax mirrors VSTACK: HSTACK(array1, [array2], ...).

Both are live. Change a number on the UK tab and the stacked range changes with it, with no refresh.

Arguments that matter

ArgumentRequiredWhat it does
array1YesThe first block. Usually a Table’s data body: UK_GL.
array2, …NoFurther blocks, appended in the order you list them.

There is nothing to configure. What matters is what you feed it.

Feed it Table references, not fixed ranges. A Table grows when rows are added, so the stack grows with it. A fixed range like UK!A2:F5000 returns every empty row to row 5000 as zeros in the middle of the stack.

Feed it data bodies, not headers. UK_GL[#All] brings the header row along, and three headers stacked means two of them land mid-data as text rows. Put one set of headers above the spill and stack the data only.

Feed it the same columns in the same order. VSTACK stacks by position, not by name. If the US tab has Amount before Date, dates land in the amount column with no error.

In a financial model

The use is light consolidation. A group with a handful of subsidiaries, each sending a trial balance or ledger extract into its own tab with a common layout, needs one combined dataset for the group P&L. VSTACK builds it in one cell, and SUMIFS or GROUPBY reads it.

Compare that with Power Query, which the play on transforming in Power Query, not in cells favors for most data shaping. Power Query wins on volume, on cleanup, and on sources outside the workbook. VSTACK wins on latency: no refresh, so a late adjustment on one entity tab shows in the group numbers immediately. Use VSTACK when the entity tabs are already clean, the row count is in the tens of thousands rather than millions, and the inputs live in the workbook. If the entity files arrive as CSVs instead of tabs, IMPORTTEXT can load each one by formula for VSTACK to stack. It is still in preview, and the stack then only updates on Refresh All.

HSTACK covers the time axis. A forecast model often holds actuals and forecast as separate blocks with months running across. HSTACK(Actuals, Forecast) joins them into one continuous row of months for a full-year view, with the actual months first.

Worked example

Three entity tabs, each with a Table of the same five columns: Date, Code, Line, CostCenter, Amount. The Tables are UK_GL, US_GL and DE_GL. None carries an entity column, because each tab is one entity.

On a tab Group, headers typed in row 4, and in A5:

=LET(
  tag, LAMBDA(t, name, HSTACK(EXPAND(name, ROWS(t), 1, name), t)),
  VSTACK(tag(UK_GL, "UK"), tag(US_GL, "US"), tag(DE_GL, "DE")))

The tag helper prefixes each block with a column holding its entity code, so the stacked data still knows where each row came from. EXPAND pads the one-cell label down to the height of the Table.

EntityDateCodeLineAmount
UK31-Jan-264000Revenue-125,000
UK31-Jan-266100Salaries48,000
US31-Jan-264000Revenue-310,000
DE31-Jan-266100Salaries52,500

CostCenter is left out of the illustration. The group P&L reads the spill with SUMIFS, using INDEX to pick columns:

=SUMIFS(INDEX(A5#, 0, 6), INDEX(A5#, 0, 4), $B12)

Then the check. The stacked total has to equal the sum of the entity totals:

=SUM(INDEX(A5#, 0, 6)) - SUM(UK_GL[Amount], US_GL[Amount], DE_GL[Amount])

Expected zero. Place it in the check row, per build a check row and make it loud.

Old way vs new way

The legacy route was copy-paste each month, or a Power Query append:

Power Query editor: Home > Append Queries as New > Three or more tables
  UK_GL, US_GL, DE_GL > Close & Load

The new version:

=VSTACK(UK_GL, US_GL, DE_GL)

Copy-paste goes stale the moment an entity posts a correction, and Power Query waits for a refresh. VSTACK reflects the entity tabs as they stand, every time the workbook calculates.

Where it breaks

#N/A fills a column at the bottom of the stack. One input has fewer columns than the others, so VSTACK padded it. Fix: give every entity Table the same columns. If a column is optional, add it empty. IFNA(VSTACK(...), "") hides the padding but also hides the layout problem, so fix the layout.

Dates appear in the amount column for one entity. That entity’s columns are in a different order, and VSTACK stacks by position. Fix: reorder the Table columns, or select them explicitly with CHOOSECOLS before stacking.

Text rows saying “Date” and “Amount” appear mid-data. The inputs included header rows. Fix: stack Table data bodies, not [#All] and not ranges that start at the header.

Blocks of zeros sit between entities. The inputs are fixed ranges sized beyond the data, and empty cells come through as 0. Fix: convert the inputs to Tables, or trim them with a trim reference such as UK!A2:.F5000.

VSTACK returns #SPILL!. An entity grew and the stack now runs into something below it. Fix: give the stack its own tab with nothing underneath.

The group tab slows to a crawl. The stack is hundreds of thousands of rows and every dependent SUMIFS rescans it on each change. Fix: move the append into Power Query, where it runs on refresh instead of on every edit.

VSTACK or HSTACK returns #NAME?. The workbook opened in Excel 2021 or earlier. Fix: if the file must travel, load the consolidation through Power Query, which older versions can refresh.

Related functions

  • SUMIFS. Reads the stacked range to build the group grid.
  • GROUPBY. Summarizes the stack by line and entity in one formula, without a grid of SUMIFS.
  • CHOOSECOLS. Align entity tabs whose columns differ before stacking, or pull single columns out of the spill.
  • FILTER. Pull one entity, or one cost center, back out of the consolidated block.
  • TRIMRANGE. When the entity tabs are raw pastes rather than Tables, trim each input so empty rows do not stack.
  • TAKE. Cut the stack down to the latest periods for a quick review.
  • INDIRECT. The older way to read a list of tabs by name. Volatile and invisible to Trace Precedents; the 3D reference in VSTACK replaces it.
  • EXPAND. Pads an array to a set size. Used above to tag each block with its entity.

All functions