Google Sheet - Google Script and Importrange formula returns sometimes blank cells

51 Views Asked by At

I wrote the following formula which works fine but sometimes, randomly during the day, it returns blank cells. Blanks cells remain there for an undifined period of time (minutes or hours) after that magically the formula returns to work.

=IF(A5="";"";INDEX(importrange("https://docs.google.com/spreadsheets/d/XXX";"YYY!$A:$AZ");MATCH($A5; importrange("https://docs.google.com/spreadsheets/d/XXX";"YYY!$A:$A");0);MATCH(F$3; importrange("https://docs.google.com/spreadsheets/d/XXX";"YYY!$3:$3");0)))

I didn't find a way to fix the problem when happen. Refresh the page, the formula or cut/paste the formula are attempts which did not work.

I also tried to import data from a Google Sheets file to a different one with a script. It works but sometimes it loses data such as a column and then.

// listini_privati > anagrafica_prodotti

function importData() {
  var sourceSpreadsheetID = '1JVYYOKaRYgFPgY09sfM_c6xatIuznxNmRLXwDLVMVf8'; // ID del documento sorgente > anagrafica_prodotti
  var sourceSheetName = 'EXPORT_listini_privati'; // Nome del foglio nel documento sorgente
  var targetSpreadsheetID = '1k61XcpCJbu7cl8aKdojKDZmyyKzzMjJ_jAHamCPfxtY'; // ID del documento di destinazione
  var targetSheetName = 'IMPORT_anagrafica_prodotti'; // Nome del foglio nel documento di destinazione

  var source = SpreadsheetApp.openById(sourceSpreadsheetID).getSheetByName(sourceSheetName);
  var target = SpreadsheetApp.openById(targetSpreadsheetID).getSheetByName(targetSheetName);

  var range = source.getRange('A:Z' + source.getLastRow());
 // Range Specifico var range = source.getRange('A:Z' + source.getLastRow()); source.getDataRange()
  var values = range.getValues();

  target.getRange(1, 1, values.length, values[0].length).setValues(values); // Scrive i valori nel foglio di destinazione
}

Any suggestions, workaround, etc?

0

There are 0 best solutions below