Analistable

How to merge Google Sheets into one

By the Analistable team · Updated · 2 min read

To merge tabs in the same file, create a new tab and enter =QUERY(VSTACK(Jan!A2:D, Feb!A2:D, Mar!A2:D), "select * where Col1 is not null", 0). To merge other files, replace each range with IMPORTRANGE("spreadsheet URL", "Tab!A2:D") and click Allow access once per file. The result updates automatically when the sources change.

Part of our guide: How to combine data in Google Sheets

Merge tabs in one spreadsheet

  1. Add a tab called Combined and type the header row in row 1.
  2. In A2, enter =VSTACK(Jan!A2:D, Feb!A2:D, Mar!A2:D).
  3. Open-ended ranges (A2:D) include empty rows at the bottom of each tab, which appear as gaps. Wrap the formula in QUERY to drop them:
=QUERY(VSTACK(Jan!A2:D, Feb!A2:D, Mar!A2:D), "select * where Col1 is not null", 0)

Inside QUERY, columns from a combined range are called Col1, Col2… not A, B. The final 0 tells QUERY there's no header row in the data.

={Jan!A2:D; Feb!A2:D} is the older array-literal way to do the same. In locales that use a comma as the decimal separator, the column separator inside {} is a backslash and the row separator is a semicolon.

Add a column showing the source tab

=ARRAYFORMULA(LET(
  j, FILTER(Jan!A2:D, Jan!A2:A<>""),
  f, FILTER(Feb!A2:D, Feb!A2:A<>""),
  VSTACK(HSTACK(IF(INDEX(j,,1)<>"", "Jan", ""), j),
         HSTACK(IF(INDEX(f,,1)<>"", "Feb", ""), f))
))
Combined tab with a source column
TabDateRegionProductUnits
Jan2026-01-04NorthDesk12
Jan2026-01-09SouthChair30
Feb2026-02-02NorthLamp14

Merge separate Google Sheets files

Use IMPORTRANGE for each file inside VSTACK:

=QUERY(VSTACK(
  IMPORTRANGE("https://docs.google.com/spreadsheets/d/AAA…", "Sales!A2:D"),
  IMPORTRANGE("https://docs.google.com/spreadsheets/d/BBB…", "Sales!A2:D")
), "select * where Col1 is not null", 0)

The first time, each IMPORTRANGE shows #REF! with an Allow access button. Click it once per source file. Tips for many files, permissions and slow loading: using multiple IMPORTRANGE formulas.

Merge without formulas

Merging matches columns by position. If tabs have different column orders, reorder them with QUERY's select (for example select Col2, Col1, Col3) before stacking.

Common problems

Problems when merging Google Sheets
ProblemFix
Gaps between the blocksWrap in QUERY(..., "where Col1 is not null", 0)
#VALUE! or #N/A paddingTabs have different numbers of columns; select the same width from each
Data in wrong columnsTabs have different column orders; reorder with QUERY select
#REF! on IMPORTRANGEClick Allow access in the cell

Frequently asked questions

How do I merge multiple tabs into one in Google Sheets?
Use =VSTACK(Tab1!A2:D, Tab2!A2:D) on a new tab, wrapped in QUERY(..., "select * where Col1 is not null", 0) to remove blank rows.
How do I merge two Google Sheets files?
Use IMPORTRANGE for each file inside VSTACK, and allow access the first time.
Will the merged sheet update automatically?
Yes. VSTACK, QUERY and IMPORTRANGE recalculate when the source data changes.

Related guides