How to combine data in Google Sheets
By the Analistable team · Updated · 3 min read
To stack tabs in one Google Sheet, use =VSTACK(Jan!A2:D, Feb!A2:D) or the array literal ={Jan!A2:D; Feb!A2:D}, then wrap it in QUERY(..., "where Col1 is not null") to drop blank rows. To pull data from other files, use IMPORTRANGE. To match two sheets by an ID, use XLOOKUP.
Pick the right function
| Goal | Function | Example |
|---|---|---|
| Stack tabs in the same file | VSTACK or { ; } | =VSTACK(Jan!A2:D, Feb!A2:D) |
| Stack and filter in one step | QUERY over an array | =QUERY({Jan!A2:D; Feb!A2:D}, "where Col1 is not null") |
| Bring in data from another file | IMPORTRANGE | =IMPORTRANGE("url", "Sales!A1:D") |
| Match rows by a key | XLOOKUP | =XLOOKUP(A2, Customers!A:A, Customers!B:B) |
| Combine text from cells | TEXTJOIN or & | =TEXTJOIN(" ", TRUE, A2:C2) |
Stack tabs into one
Open a new tab and enter =VSTACK(Jan!A2:D, Feb!A2:D, Mar!A2:D). Open-ended ranges such as A2:D include every row, so blank rows at the end of each tab appear between the blocks. Filter them out with QUERY:
=QUERY(VSTACK(Jan!A2:D, Feb!A2:D, Mar!A2:D), "select * where Col1 is not null", 0)
Inside QUERY, columns from an array are named Col1, Col2… rather than A, B. Full guide: merging Google spreadsheets and QUERY with multiple ranges.
Combine data from other spreadsheets
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/…", "Sales!A1:D") pulls a range from another file. The first time, click Allow access in the cell. To stack several files, put IMPORTRANGE calls inside VSTACK. See using multiple IMPORTRANGE formulas.
Join two sheets by a key
QUERY can't join two tables, so matching rows needs a lookup. =XLOOKUP(A2, Customers!A:A, Customers!C:C, "") brings the matching value across; with ARRAYFORMULA or MAP you can fill a whole column at once. Walkthrough: linking two Google Sheets.
When formulas aren't enough
Large IMPORTRANGE stacks recalculate slowly, and a formula can't do a many-to-many join. For a scheduled merge, use Google Apps Script. To ask questions across several Google Sheets and Excel files without building formulas, connect them in Analistable: it joins them on the column you confirm and answers in plain language.
Worked example: three regional tabs
Tabs North, South and West have the same columns: Date, Product, Units. On a Summary tab:
=QUERY(VSTACK(North!A2:C, South!A2:C, West!A2:C),
"select Col2, sum(Col3) where Col1 is not null group by Col2 label sum(Col3) 'Units'", 0)| Product | Units |
|---|---|
| Chair | 96 |
| Desk | 41 |
| Lamp | 27 |
The formula stacks the tabs, removes the empty rows the open-ended ranges add, and totals by product — and it updates when someone adds a row to any tab.
Limits to plan for
| Limit | Value | What it means |
|---|---|---|
| Cells per spreadsheet | 10 million | Includes the combined tab and every source tab |
| Formula recalculation | Slows with large imports | Import only the columns you need |
| QUERY | One table per query | Use lookups to combine tables by key |
| Apps Script run time | 6 minutes per execution | Split very large merges into batches |
When a combined sheet becomes slow, move the merge from live formulas to a scheduled script that writes static values, or analyse the files outside Sheets.
Common mistakes
- Using A, B, C inside QUERY over a stacked array — it must be Col1, Col2, Col3.
- Stacking tabs whose columns are in a different order: VSTACK matches by position, so reorder first.
- Forgetting that IMPORTRANGE needs Allow access once per source file.
- Mixing numbers stored as text with real numbers in one column: QUERY treats the minority type as empty.
Google Sheets vs Excel for combining data
Google Sheets combines tabs and files with live formulas and is easy to share. Excel adds Power Query, which can stack a whole folder of files, merge tables with any join type and refresh in one click. If your sources are a mix of both, see joining spreadsheets or export everything to one format first.
Every guide in this topic
- How to combine multiple IMPORTRANGE formulas
Stack data from several Google Sheets files with VSTACK and IMPORTRANGE, filter it with QUERY, and fix access errors, slow loading and size limits.
- How to link two Google Sheets
Link two Google Sheets: reference cells, pull rows with IMPORTRANGE, and match records by ID with XLOOKUP or VLOOKUP — for one cell or a whole column.
- How to merge Google Sheets into one
Merge tabs or whole Google Sheets files into one: VSTACK and array literals, QUERY to drop blanks, a source column, and IMPORTRANGE for other files.
- How to merge sheets with Google Apps Script
A copy-ready Google Apps Script that merges tabs or files into one sheet with a source column, plus how to run it on a schedule with a time-driven trigger.
- How to use QUERY with multiple ranges in Google Sheets
Run one QUERY over several tabs or ranges in Google Sheets: stack them in { ; }, use Col1 notation, group and sum, and avoid the common errors.
Frequently asked questions
- How do I combine multiple tabs into one in Google Sheets?
- Use =VSTACK(Tab1!A2:D, Tab2!A2:D) or ={Tab1!A2:D; Tab2!A2:D}, and wrap it in QUERY(..., "where Col1 is not null") to remove blank rows.
- How do I combine data from multiple Google Sheets files?
- Use IMPORTRANGE for each file and stack the results with VSTACK. You need to allow access once per source file.
- Does Google Sheets QUERY support joins?
- No. QUERY works on one table at a time. Use XLOOKUP, VLOOKUP or FILTER to match rows from another sheet.
- What's the difference between VSTACK and { ; } in Google Sheets?
- They stack ranges the same way. VSTACK pads shorter ranges with #N/A, while an array literal returns an error if column counts differ.