How to combine multiple IMPORTRANGE formulas
By the Analistable team · Updated · 2 min read
Put each IMPORTRANGE inside VSTACK (or { ; }) to stack several files: =VSTACK(IMPORTRANGE(url1, "Sales!A2:D"), IMPORTRANGE(url2, "Sales!A2:D")). Wrap it in QUERY(..., "where Col1 is not null", 0) to drop blank rows. Each source file needs Allow access once, and every file must have the same columns in the same order.
Part of our guide: How to combine data in Google Sheets
The formula
=QUERY(VSTACK(
IMPORTRANGE("1AbC…north", "Sales!A2:D"),
IMPORTRANGE("1AbC…south", "Sales!A2:D"),
IMPORTRANGE("1AbC…west", "Sales!A2:D")
), "select * where Col1 is not null", 0)You can pass the full URL or just the spreadsheet key (the long ID between /d/ and /edit).
Keep the file list in cells
IMPORTRANGE accepts a cell reference for the spreadsheet, so keep the source URLs or keys in a Sources tab and refer to them: IMPORTRANGE(Sources!A2, "Sales!A2:D"). Replacing a file then means editing a cell, not the formula. Each new source still needs Allow access the first time.
Errors and fixes
| You see | Cause | Fix |
|---|---|---|
| #REF! “You need to connect these sheets” | Access not granted yet | Click the cell, then Allow access |
| #REF! “You don't have permission” | Your account can't open the source | Ask the owner to share it with you |
| Loading… for a long time | Large ranges or many imports | Import only the columns and rows you need |
| “Result too large” | The imported range is too big | Split it into smaller ranges or filter at the source |
| Columns don't line up | Different column order in a source | Reorder with QUERY(IMPORTRANGE(...), "select Col2, Col1…") |
Performance tips
- Import closed ranges (A2:D5000) rather than whole columns when you know the size.
- Import each file once into its own hidden tab, then stack the tabs. Lookups against a local tab are faster than repeated IMPORTRANGE calls.
- Avoid volatile functions (NOW, RAND) in the source files; they make imports refresh constantly.
For many large files, a scheduled Apps Script merge writes values once instead of recalculating live.
Worked example
| Region | Date | Product | Units |
|---|---|---|---|
| North | 2026-09-01 | Desk | 4 |
| North | 2026-09-03 | Lamp | 9 |
| South | 2026-09-02 | Chair | 12 |
| West | 2026-09-02 | Desk | 3 |
Each regional file has a Region column, so the source survives the stack. If yours don't, add one in each source file — IMPORTRANGE can't add a constant column on its own, though you can wrap each import in HSTACK with a repeated label.
Alternatives
For a handful of files, IMPORTRANGE is the simplest option. For dozens, or when the combined data feeds other heavy formulas, a scheduled Apps Script merge is faster because it writes values once.
Frequently asked questions
- Can I use IMPORTRANGE with multiple spreadsheets?
- Yes. Put several IMPORTRANGE calls inside VSTACK or an array literal { ; } to stack them.
- Do I have to allow access for every IMPORTRANGE?
- Once per pair of files. After that, every IMPORTRANGE from the same source file works.
- Why is IMPORTRANGE so slow?
- Each call fetches data from another file. Import fewer columns, use closed ranges, and import each file once.