Why does =Importrange() cause a #name error in Google Sheets? - google-sheets

ImportRANGE returns a #NAME error occasionally as it updates itself every 30 mins.
I took a look through Google Sheet Script Returning #NAME? but there sadly wasn't any solutions. The best guess at a response was about how google sheets loads custom formulas, but since =IMPORTRANGE() is a vanilla formula it shouldn't have a problem with that.
My formula is
=IMPORTRANGE("URLHERE",(A5&"!"&"D1"))
First the URL, then the final section allowing it to request data from a different sheet in the file for every line. I have setup the sheets that contain the source data to be called 1,2,3,4, ect up to 100 to accomodate for this.
I am trying to import data from a different sheet that has a custom script running to import JSON data. The JSON is imported perfectly and once a day a macro will run that updates the JSON values. I have a separate sheet that I don't want to run the script on, so I am using IMPORTRANGE to get the data from JSON imports. Every 30 minutes Importrange updates itself and it researches for the values. It would work fine for me for this to be once a day, however, I can't find a way to change that.
Most of the time it has no problems, occasionally it has a problem with a couple of the imports but most are fine. A couple of times it has hit #NAME on every single IMPORTRANGE.

Related

Google Sheets IMPORTRANGE and QUERY not refreshing

I have been using IMPORTRANGE and QUERY extensively to connect all of my spreadsheets for a while now. But recently noticed that IMPORTRANGE and QUERY will not return proper data unless the source Sheet is open. Also, the data used to automatically update (every 30 min or so, whatever the default refresh rate is) in the background for IMPORTRANGE, but now it will only update if I manually open the Sheet and it will display "Loading...." before returning the data.
Is anybody else having issues with these two functions?
This answer explains the issue you encountered.
In summary:
It doesn't update when the sheet isn't opened.
Recalculation only happens when sheet is opened.
Functions that pull data from outside the spreadsheet recalculate at the following times:
ImportRange: 30 minutes
ImportHtml, ImportFeed, ImportData, ImportXml: 1 hour
GoogleFinance: may be delayed up to 20 minutes
Alternative solution:
You can use time driven triggers and update those values every N minutes/hours instead BUT you will have to create a script for that.
Everytime you trigger, you'd have to use setFormula on every cell you used your importrange and query.
References:
setFormula
Choose how often formulas calculate
Time Driven Triggers

I cant import data from another big sheet

Im having trouble importing data from my another sheet. Its quite big, has over 500 rows and to 100 columns. (I dont know if thats important but it has about 50 sheets, I want to import from first biggest one)
Importhtml and importdata take too long to load and then say that source is too big.
But what I want is importrange and that says internal error all the time.
Do you have any advice how can I import my data? Maybe even how to change source so it can be imported from?
Sheet I want import to
The function to use is IMPORTRANGE
=IMPORTRANGE("XXXXXXXXXX";"Prices!A1:AJ")
(where XXXXXXXXX is the sheet ID)
Pro tip
But what I want is importrange and that says internal error all the time.
A good practice is to first link the two sheets by using a very small range like:
=IMPORTRANGE("XXXXXXXXXX";"Prices!A1:A3")
and then change the range to meet your needs
=IMPORTRANGE("XXXXXXXXXX";"Prices!A1:AJ")
Try coupler.io.
It has a free plan and allows to COPY the data from one spreadsheet to another on a schedule. It means you can split your calculations, make heavy ones on one spreadsheet and then copy results to the one when you work with them.
It also allows to import from CRM, financial apps etc, but your case is covered with GSheet -> Gsheet import.

Using IMPORTRANGE as an array formula

I have a URL in one cell which is the criterion for the IMPORTRANGE. e.g.:
=IMPORTRANGE(B2,"sheet1!$A$1")
I found a formula to collect it as criterion, but not in array version.
A sample can be found here.
I see you have column B filled with Spreadsheet Ids, and you are trying to execute
=ArrayFormula(IMPORTRANGE(B2:B,"sheet1!$A$1"))
Not every spreadsheet function supports arrays as argument. In particular, importrange does not. You need separate importrange formulas for separate spreadsheets you are importing.
Indeed, importing data from another spreadsheet is not a batch operation; each import has to be authorized by clicking a prompt the first time it's called. Also, it's a very slow operation; you will get a serious performance
hit if trying to import a lot of other spreadsheets.
Generally, if you find yourself doing a lot of importrange, it may be time to rethink the overall data organization.
While you cannot use IMPORTRANGE() in an arrayformula, as detailed in the other answer, you can use it in an array literal. In your case, for the first five cells in your column B that contain spreadsheet URLs:
={
IMPORTRANGE(B2,"sheet1!$A$1");
IMPORTRANGE(B3,"sheet1!$A$1");
IMPORTRANGE(B4,"sheet1!$A$1");
IMPORTRANGE(B5,"sheet1!$A$1");
IMPORTRANGE(B6,"sheet1!$A$1")
}
So you'll have to write IMPORTRANGE() multiple times and you can only use this technique if you know before how many sheets there are to import. But the advantage is that this also works where IMPORTRANGE() returns multiple rows each – in that case, copying the formulas down is no option, as IMPORTRANGE() creates an error in cases where its results would overwrite cell contents further down.

"Unresolved Sheet Name" errors randomly shown across my cells

This started happening to me today, almost randomly my functions show "Unresolved Sheet Name". I have to go into the function, as if I was editing it, and just hit Enter and it works like normal. The issues is I have thousands of functions across several sheets and they keep intermittently "breaking" on their own terms.
This is similar to: Google Spreadsheet Import Range #REF! Error (Randomly).
I have a spreadsheet holding a large chunk of data which I import to the current spreadsheet I'm using. I then reference the worksheet I used to importrange the data into. The reference to that worksheet will intermittently break.
I see no reason to paste my functions, since they do work as long as this #REF error does not show up.
Is this a known bug?
I've had this happen before in the past, and eventually resolved to just "refresh" all my functions every time this happened. In this case, the spreadsheets are client facing and need to be reliable so I don't have that option.
Any way to "refresh" all my functions without going through them one at a time?
I had a similar issue that I corrected with script. My spreadsheet references sheets that aren't yet created. This results in a "ref" error as expected. However, when I create the sheet, the "ref" error only goes away when I click in the cell and then hit "enter."
Since I had already written a script to update my sheet monthly, I added the following to the end (I only needed to update 12 cells, hence the range):
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Random Notes/Calcs");
var formies = ss.getRange(31, 24, 12, 1).getFormulas();
ss.getRange(31, 24, 12, 1).setFormulas(formies);
In summary, get your range, then get the formulas, and then set the formulas to the same range. I'm sure there is a better way. Hope this helps.
I have some time working with google sheets, the issue I've have is in the Import Range #REF! Error (Randomly)
Fine, the solution I found is using the ** RANDBETWEEN** and MOD
Try this
=IF(MOD(RANDBETWEEN(0,10),2)=0,IMPORTRANGE("SheetID","Sheet!a:Ab"),IMPORTRANGE("SheetID","Sheet!A:Ab"))
With the Changes, the rand formula will recalculate the number. If you see, the Range of the sheet change A by a.

Google spreadsheet CTRL+Shift+E

I have spreadsheet with two sheets: current_sheet and archive_sheet.
I also have a script (which I created) which removes data from current_sheet and appends it to archive_sheet once per month.
The sheets have an arrayFormula, and after every monthly move operation, cells with this arrayFormula wind up without any results - and I receive a warning message, indicating that I should press Ctrl+Shift+E in order to resolve the problem.
Once I've done so - the formulas work again. What I'm wondering is... how can I alter my script so that I don't have to provide this manual fix every month?
use a time driven trigger to run your script each month
Instead of using script to move your data each month, try copying the values, then clearing the original data and reinitialise the formula. Without seeing your formula and have a clear understanding of what your doing, im kinda punching in the dark.

Resources