I have a large sheet with around 30 importxml
functions that obtain data from a website that updates usually twice a day.
I would like to run the importxml
function on a timely basis (every 8 hours) for my Google Spreadsheet to save the data in another sheet. The saving already works, however the updating does not!
I read in Google Spreadsheet row update that it might run every 2 hours, however I do not believe that this is true, because since I added it to my sheet nothing has changed or updated, when the spreadsheet is NOT opened.
How can I "trigger" the importxml
function in my Google Spreadsheet in an easy way, as I have a lot of importxml
functions in it?
The Google Spreadsheet row update question and its answers refer to the "Old Sheets", which had different behaviour than the 2015 version of Google Sheets does. There is no automatic refresh of content with "New Sheets"; changes are only evaluated now in response to edits.
While Sheets no longer provides this capability natively, we can use a script to refresh the "import" formulas (
IMPORTXML
,IMPORTDATA
,IMPORTHTML
andIMPORTANGE
).Utility script
For periodic refresh of IMPORT formulas, set this function up as a time-driven trigger.
Caveats:
ScriptLock
. This may conflict with other uses of that lock in your script.I made a couple of adjustments to Mogsdad's answer:
releaseLock()
call placement...
To answer your question for an easy "trigger" to force the function to reload:
add an additional not used parameter to the url you are loading, while referencing a cell for the value of that parameter. Once you alter the content of that cell, the function reloads.
example:
unfortunately you cannot put a date calculating function into the referenced cell, that throws an error that this is not allowed.