79642273

Date: 2025-05-28 13:07:36
Score: 0.5
Natty:
Report link

After some more research, I found the following solution that decreased the time to about 12-16 sec instead of 23-30+ sec.
'

function onOpen(){

const ss = SpreadsheetApp.getActive();
ss.getSheets().forEach((sheet,index) => {
  if (index <9) {
  hideRows();
  sheet.setActiveSelection('B4');
  }else{
  if (index < 11){
  sheet.setActiveSelection('A1')
  }
  }
});
ss.getRange('Active(Date)!B4').activate();

}

function hideRows() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  // Iterate through each row and hide if all cells are blank
  for (var i = 0; i < data.length; i++) {
    var row = data[i];
    if (row.every(function(cell) { return cell === ''; })) {
      sheet.hideRows(i + 1);
    }
  }
}
`
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Doc