15
votes

This problem has been persistent for a while, just happens every so often at random times, nothing changing. I also do not know how to reproduce the problem, but I'll give a detailed explanation of what's happening.

Normally the importRange function works just fine, and looks something like the following:

enter image description here

The Spreadsheet key is typed correctly - I've been using this strategy in Google Spreadsheets for a while now.

Every so often, Google Spreadsheets seems to break down, or at least the importRange function does... and produces something like the following:

enter image description here

Google seemed to be freezing up at times today, which is when this happened. I've tried adjusting the importRange parameters to !X1:X, !X2:X5, changing the title of the Sheet that is being imported, etc.

In the past, changing from !X:X to !X1:X fixed some columns, but not always all of them. The only fool-proof solution to fixing this, that I have found, is recreating both spreadsheets. As the back-end (the one being imported) eventually becomes a report, I would like to spare my boss the extra effort of referencing multiple spreadsheets, and would rather just fix this and be done with it.

Does anyone know the potential cause of this glitch? Sometimes it fixes itself, sometimes it doesn't. It happens randomly, and only to certain spreadsheets (I have a set of 8 or so that all use importRange, and no more than 2 are ever affected at the same time). So I honestly have no clue where this is coming from.

Side note: Google in general has been a bit unresponsive today in terms of all its services - my university's App Engine email service was down for about half an hour. Could a limitation on resources/network attackers be causing this kind of behavior in Spreadsheets?

Update: I attempted to import to the same Spreadsheet data from a different Spreadsheet (i.e., gave the importRange function a different Spreadsheet key). Though the key and range are valid if imported into a different Spreadsheet, in my original (the one full of #REF!), that range is not imported correctly. This leads me to believe that this glitch may apply only to a single Spreadsheet, where any attempt to importRange from any other source is not functional.

11
I've seen such behavior as well, I think the importRange function is just broken. I use Apps Script to replace it nearly everywhere. Anyway, why you tagged this question as apps-script? It doesn't seem to be related. Or are you looking for a apps-script replacement solution as well? :)Henrique G. Abreu
Well, the idea is to have a non-editable range that is pulled from a resource spreadsheet. I can do the same with protected ranges but I also want the values to update if the original spreadsheet's values are updated. I also tagged this as GAS because I know that certain people who follow that tag have used importrange before, and have experience with scripting around its failures. It seems that importrange is just plain broken, and has been for a while. See this question.Chris Cirefice
The question it's not related directly to google-apps-script so this tag should be removed.Rubén
This is still an issue today. A shame because it's a great thinglearn2day

11 Answers

12
votes

This is a little late, but I came across it in a search so it might help someone else - try something like this:

=IFERROR(ImportRange(SpreadSheet_GUID,"Bookings!P:P"), 
 IFERROR(ImportRange(SpreadSheet_GUID,"Bookings!P:p"), 
 IFERROR(ImportRange(SpreadSheet_GUID,"Bookings!p:P"), 
         ImportRange(SpreadSheet_GUID,"Bookings!p:p"))))

Basically the idea is to force Google to recalc using variations of the original address (upper/lower case column letters).

5
votes

The problems with the IMPORTRANGE() function has been somewhat of an ongoing issue. There have been several bugs over the years and it is up to Google to find a stable solution so it works as designed.

Until then, this might help you:

Instead of editing the cell, creating a new spreadsheet, or doing anything else to have the sheet reattempt the function (almost like playing lottery), you can force Google sheets to reattempt the function automatically when it fails to load:

Wrap the IMPORTRANGE() function that is causing problems with an IFERROR() function. That way, the sheet attempts the import, and only if it fails, it attempts it again. The function can be nested to attempt several times in a row.

You can add named ranges to your source data (right-click-source>define-named-range) to facilitate. For instance, you can create 3 different named ranges for the "J:J" range. Call them "J", "Ja", and "Jay", then you call on your IFERROR() function in the sheet you want to import to:

=IFERROR( IMPORTRANGE( "SheetID","J" ), IFERROR( IMPORTRANGE( "SheetID","Ja" ), IFERROR( IMPORTRANGE( "SheetID","Jay" ), IFERROR( IMPORTRANGE( "SheetID", "'TabName'!J:J" ), IFERROR( IMPORTRANGE( "SheetID", "'TabName'!j:j" )))))

This formula will attempt your import and deliver it if it succeeds, and if not reattempts a total of 5 times in a row automatically, which doesn't guarantee you will succeed, but if you have a 50% chance of success with your imports, nesting 5 in a row should give you a 96% chance, which is a lot better. My personal experience has been that it hasn't failed since I've done the IFERROR() nest.

Hope it helps.

4
votes

I had similar issues, and were resolved by NOT using public links to spreadsheets. I have noticed that links are different for public sharing and those coppied from address bar while sheet si opened.

Also i have noticed some difficulties while opening shared spreadsheets from my other Google accounts. I had to re-allow access for some spreadsheets that i was importing.

Sorry for my english.

2
votes

This happens, indeed, in my case simply Ctrl+X, waiting for a second, and then pasting the formula back makes the Sheets engine re-do the import and then it succeeds to import. In case you can not do this procedure manually, you should use Tim's solution.

0
votes

I had the same issue, and found a solution!

  1. Please reduce the source file's size

  2. To reduce, split it up and again have the import-range referenced

You now will be able to see the imported range!

If you think the above isn't the situation, the chances might be

  1. Your cell is occupied so remove all formatting and clear all the cells before importing the range.

  2. Still not working? Let God help you out!

0
votes

I tried adding :

if(ISERROR(importrange... 

and it works.

It doesn't mean the error disappears, but when it happens, you just need to reload the sheet and wait for while and let it update itself.

It is much more practical than manually changing the big letter to small letter.

0
votes

Here's the easy work-around I've found for this bug:

I do a Find-and-Replace ("search within formulas") for "=" wherever I have the importrange error (=REF!) (or just for the whole sheet) and I replace-all with a "#" in order to make it all be text rather than formula. Then I do another Find-and-Replace over the same area and replace-all the "#" with "=" again. This consistently fixes the issue.

0
votes

I found this solution, work fine for me:

In both spreadsheets insert an =now() equation in a random cell, say Z1 In both spreadsheets insert an =importrange() function that references the now function of the other spreadsheet. Go into your spreadsheet settings and choose to recalculate on every minute. I tried a lot of other suggestions including using the =now() function, the now URL trick in this thread, or Apps Script to insert random text on a set interval, but nothing would force importrange to update except a manual edit of the source sheet.

https://webapps.stackexchange.com/questions/60324/how-can-i-get-google-sheets-to-auto-update-a-reference-to-another-sheet

0
votes

I was able to fix the =REF! error using the Edit > Find and Replace > Find "=" Replace with "#" > Search Selected Range > Also search within formulas > Find > Done. The error corrected without actually initiating the Replace command.

0
votes

just to share with you how I resolve this error. Upon checking on my formulas, I have a Circular Reference, which made me encounter this ImportRange internal Error. When I clean my formulas to remove those circular references, it worked again. :)

-1
votes

I had the same problem and solved it by using =IF(ISERROR(A1);IMPORTRANGE();IMPORTRANGE()) in the cell where earlier IMPORTRANGE used to be and by turning on Iterative calculation in spreadsheet’s location & calculation settings. Hope it help someone