I've built a spreadsheet that has 7 sheets, each of which is filled with many rows of data. I got tired of manually scrolling down to the last row of each sheet, so I constructed a simple script function to programmatically find and go to a sheet's last row. This function works, for the most part, when run manually. However, when I tried to execute this function with a "From Spreadsheet, On Open" installed event trigger, it doesn't fire properly.
Here's the function:
function LastRowOnOpen() {
var ss = SpreadsheetApp.getActive();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('302 Ashfrd'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('3220 Blmnt'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('3302 Blmnt'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('1035 Bnhm'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('Deer Park'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('3000-102 Lrn'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
var sheet = SpreadsheetApp.setActiveSheet(ss.getSheetByName('2249 Wht'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet();
P.S.
I also tried using a for loop containing:
var sheet = SreadsheetApp.setActiveSheet(ss.getSheetByName('2249 Wht'));
var lastRow = sheet.getLastRow();
lastRow = lastRow + 5;
sheet.getRange(lastRow, 1).activate();
sheet.showSheet(); `
varying the sheet = getSheetByname
method to reduce lines of code, however all but the last iteration of the loop was ignored.
Not sure whether you still need the answer or not since this thread was opened back in 2018 but I found the answer to your issue with "jumping to the last row" of an active spreadsheet here.
The script was written by Kory Becker (primaryobject) 6 months ago.