I have a spreadsheet that imports from various websites 10 tables using importhtml. I have a refresh script which helps me to update that data every 30 minutes. This is working fine. My problem is that plenty of times one or more of the importhtml fails which has as result all the cells that are using the data i am importing to give wrong results. Is there any way to keep the data I had taken earlier from importhtml if there is an error at refreshing?
CodePudding user response:
maybe not what you need, but try to wrap your imports into 1-2 IFERRORs like:
=IFERROR(IMPORTHTML(...); IMPORTHTML(...))
or:
=IFERROR(IFERROR(IMPORTHTML(...); IMPORTHTML(...)); IMPORTHTML(...))
this way if some importing error occurs the IFERROR will re-try it. it may help in some cases - ofc not always.
CodePudding user response:
Thanks for the answer. I tried it but still I get the same results. I think the solution should be a custom function eg MyImporthtml which will work as below
Store the data of next 30 rows and 10 columns to a variable from the cell that is called since that's the maximum size of tables I get. Probably the range could be a parameter.
Call the importhtml function
When I use importhtml at cell A1 if it fails I get N/A at A1 and the rest cells of range are empty otherwise they contain data. So the last thing the custom function should do is to check if eg A2 is empty and if yes to restore the data that were stored in variable to the range.
I have very few experience at writting custom functions to do it myself and I don't even know if this can be done but that's what I think is the proper solution.