Answers / Question 16

IMPORTRANGE shows #REF! in Google Sheets: every cause and how to fix it

Why IMPORTRANGE returns #REF!: the sheets aren't connected yet, the URL or range string is wrong, a tab was renamed, the result is too large, cells are in the way, or you can't open the source file.

The problem

You use IMPORTRANGE to pull data from another spreadsheet, and the cell shows #REF! instead of data. Sometimes it worked yesterday, sometimes the same formula works in one file and not in another, and when it's buried inside QUERY or VLOOKUP it may just show blanks. Hover over the cell (or click it): the message in the error box tells you which of the causes below you're dealing with.

Inspired by a public question on Stack Overflow. The problem above is described in our own words and the solution below is ours.

Cause 1: the sheets aren't connected yet

The first time a file imports from a new source, Google asks for permission. The cell shows #REF! with You need to connect these sheets, and clicking the cell shows an Allow access button. Press it and the data appears. Access stays in place for that pair of files, and from then on any editor of your file can import from the source.

The catch: when IMPORTRANGE is nested inside another function, or wrapped in IFERROR, the prompt often never shows, so you just see blanks or your fallback value. Put a bare import in a spare cell, allow access there, then delete it:

Connect once in an empty cell (then delete it)Formula
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/SOURCE_ID/edit", "Orders!A1")

Leave IFERROR off until the import works; it hides the very message you need.

Cause 2: you can't open the source file

If the error says you don't have permission, the account you're using can't view the source spreadsheet. Open the source URL in your browser and request access, or ask its owner to share it with you (view access is enough). Then go back and press Allow access.

Two less obvious ones: the connection stops working if the person who originally allowed it loses access to the source, and if the source owner turns on Disable options to download, print, and copy, new IMPORTRANGE formulas can't read from it (ones set up before keep working).

Cause 3: the URL or the range string is wrong

Both arguments are text, so both go in double quotes (or point at a cell holding the text). Copy the URL straight from the address bar of the source file, or use just the long ID between /d/ and /edit. If the error says the spreadsheet can't be found, the URL is the problem.

The range string is "TabName!A2:F". Tab names containing spaces or punctuation need single quotes inside the double quotes:

Tab name with a spaceFormula
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/SOURCE_ID/edit", "'Orders 2026'!A2:F")
URL kept in cell H1, so you fix it in one placeFormula
=IMPORTRANGE($H$1, "Orders!A2:F")

Cause 4: someone renamed the tab in the source

A normal reference updates itself when a tab is renamed, but IMPORTRANGE's range is just a piece of text, so it keeps pointing at the old name and breaks. Update the text, or make it rename-proof: in the source file, select the range and use Data → Named ranges to give it a name such as OrdersData. A named range follows the tab if it's renamed, and IMPORTRANGE accepts the name:

Import a named range from the sourceFormula
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/SOURCE_ID/edit", "OrdersData")

Cause 5: cells are in the way of the result

IMPORTRANGE spills its result down and to the right. If anything already sits in that area, you get #REF! with Array result was not expanded because it would overwrite data in and a cell address. Clear that cell. Often it's a leftover value, a stray space, or another formula; select the area and press Delete to be sure.

Cause 6: the result is too large

An import is capped at 10 MB of data per request, so importing whole sheets with many columns can fail with an error like Result too large. Import less: only the columns you need, and a bounded number of rows.

Bounded range instead of whole columnsFormula
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/SOURCE_ID/edit", "Orders!A2:F5000")
Just columns A and F, side by sideFormula
={IMPORTRANGE("https://docs.google.com/spreadsheets/d/SOURCE_ID/edit", "Orders!A2:A5000"), IMPORTRANGE("https://docs.google.com/spreadsheets/d/SOURCE_ID/edit", "Orders!F2:F5000")}

Wrapping a big import in QUERY doesn't help with the size limit, because the whole range is still transferred before QUERY filters it. If you only need a total, calculate it in the source file and import that single cell.

Good to know

Formulas follow documented Google Sheets / Excel behavior; they aren't machine-tested, so try them on a copy first. Always try new automations on a copy of your sheet first.