简体   繁体   中英

Hide Individual Google Sheets by Cell Value in each sheet

My script works great but only for the active sheet. How can it be changed so it searches the entire workbook and checks same cell location (example: 'AC2') in each sheet for a value of 1 or 2 and chooses whether to hide or show that sheet, and then check the others and do the same?

I've tried for days trying to find an example, but the only ones I've found are referenced to a cell in a unique spreadsheet that controls the actions for all the others and I haven't much experience with google scripts to make it check each spreadsheet at the same time. There will be about 46 sheets by the time it's finished.

I've got the triggers sorted.

Thanks so much for any help you can provide

` function yesterday2() { var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets();

  if(ss.getRange('AC2') == 1) {
    ss.hideSheet();
  }

  if(ss.getRange('AC2') == 2) {
    ss.showSheet();
   }
}

`

function yesterday2() {
  const ss = SpreadsheetApp.getActive()
  const shts=ss.getSheets();
  shts.forEach((s,i)=>{if(s.getRange('AC1').getValue()==1){s.hideSheet();}else{s.showSheet();}}); 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM