Tenho certeza de que isso é um erro meu, mas como o script funciona, não sei se é um problema que vai aparecer em algum momento. Tenho 11 abas, e o script percorrerá as primeiras 9 abas, ocultando as linhas sem dados e, em seguida, definirá o cursor de cada aba para B4, exceto as abas 10 e 11, que serão definidas para A1. Mas há uma chave vermelha e não sei como corrigi-la. Uma está no final da primeira linha, a correspondente é a linha com }); Obrigado pela ajuda.
function onOpen() {
SpreadsheetApp.getActive().getSheets().forEach(function (s,index,array) { //for each sheet
if(index<9){ //if sortable page, not maps or docs
var nameOfSheet= array[index].getName()
var ssa = SpreadsheetApp.getActive().getSheetByName(nameOfSheet) //get active sheet
var max = ssa.getMaxRows()//max rows for this sheet
var last = ssa.getLastRow() //last row with data
ssa.hideRows(last+1, max-last)
}
if(index>8){
s.setActiveSelection("A1"); //set active cell for sheet to A1 if map or documentation sheet
SpreadsheetApp.flush(); // Force this update to happen before moving to next sheet
}else{
s.setActiveSelection("B4"); //set active cell for sheet to B4 for other sheets
SpreadsheetApp.flush(); // Force this update to happen before moving to next sheet
}
});
var sheet = SpreadsheetApp.getActive().getSheetByName('Active(Date)'); //set back to first sheet
var range = sheet.getRange('B4'); //put cursor on search box
range.activate();
}