Analistable

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

IMPORTRANGE problems
You seeCauseFix
#REF! “You need to connect these sheets”Access not granted yetClick the cell, then Allow access
#REF! “You don't have permission”Your account can't open the sourceAsk the owner to share it with you
Loading… for a long timeLarge ranges or many importsImport only the columns and rows you need
“Result too large”The imported range is too bigSplit it into smaller ranges or filter at the source
Columns don't line upDifferent column order in a sourceReorder 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

Three regional files stacked with IMPORTRANGE
RegionDateProductUnits
North2026-09-01Desk4
North2026-09-03Lamp9
South2026-09-02Chair12
West2026-09-02Desk3

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.

Related guides