I tested a simple script on 2 different spreadsheets and the execution took less than 1 sec for the first spreadsheet and about 7 sec for the second spreadsheet (even though it's the same code). Here is the code, very basic (just retreiving a value in a sheet), used on the 2 spreadsheets:
function testScript() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MY SHEET");
var range = sheet.getRange("A1");
var value = range.getValues();
}
I called the fonction from the menu using this code:
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('MY MENU')
.addItem('TEST', 'testScript')
.addToUi();
}
I have nothing else in the script file.
Concerning the spreadsheets:
- The first one (less than 1 sec execution) is composed of an empty sheet called "MY SHEET".
- The second one (moredthan 7 sec execution) is composed of 9 sheets with a lot of data and formulas inside + one empty sheet called "MY SHEET" as well (to test the simple code).
Why the execution time is so different between the 2 spreadsheets? The code is exactly the same between them and I'm only dealing with the empty sheet "MY SHEET".
Thanks a lot! :)