I have the following code that I took from this question. I am trying to get my 400+ line Google sheet to auto-scroll to the bottom of the sheet on open instead of the first row. I am getting an error for the code on line 2.
TypeError: Cannot read property "source" from undefined. (line 2, file "Code")
I have a feeling it is because I have more than one tab on my spreadsheet, but I do not know code well enough to fix it. I would like it to only work on the first tab.
function onOpen(e) {
var spreadsheet = e.source;
var sheet = spreadsheet.getActiveSheet();
var lastRow = spreadsheet.getLastRow();
/* if (sheet.getMaxRows() == lastRow) {
sheet.appendRow([""]);
}
lastRow = lastRow + 1;
*/
var range = sheet.getRange("A" + lastRow + ":A" + lastRow);
sheet.setActiveRange(range);
}