Reputation: 4429
I have a simple function to move the cursor to another place of the spreadsheet. Sometime this code takes 30 seconds to execute, sometimes it takes 1 second to execute, which makes it useless. Is there a way to recode it so the execution time is more consistent?
function go_to(){
var ss = SpreadsheetApp.getActiveSpreadsheet()
var active = SpreadsheetApp.getActiveRange().getValue()
var sheet = ss.getSheetByName("Records")
var range = sheet.getRange("B"+(active+2))
sheet.setActiveRange(range)
}
Upvotes: 0
Views: 84
Reputation: 64042
This seems pretty consistent in time performance for me. How's it work on your setup?
function go_to()
{
var sht = SpreadsheetApp.getActiveSheet();
var rsht = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Records');
rsht.setActiveRange(rsht.getRange("B" + Number(sht.getActiveRange().getValue() + 2)));
}
Upvotes: 1