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
- Add a tab called Combined and type the header row in row 1.
- In A2, enter
=VSTACK(Jan!A2:D, Feb!A2:D, Mar!A2:D). - 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))
))| Tab | Date | Region | Product | Units |
|---|---|---|---|---|
| Jan | 2026-01-04 | North | Desk | 12 |
| Jan | 2026-01-09 | South | Chair | 30 |
| Feb | 2026-02-02 | North | Lamp | 14 |
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
- Copy and paste each tab's rows into one tab — static, but simple.
- A script that copies rows on a schedule — see merging sheets with Apps Script.
- Download the tabs as .xlsx or CSV and use the Sheets & Excel combiner, which stacks them in your browser.
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
| Problem | Fix |
|---|---|
| Gaps between the blocks | Wrap in QUERY(..., "where Col1 is not null", 0) |
| #VALUE! or #N/A padding | Tabs have different numbers of columns; select the same width from each |
| Data in wrong columns | Tabs have different column orders; reorder with QUERY select |
| #REF! on IMPORTRANGE | Click 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.