0
votes

I am trying to make the following script run on all the sheets(tabs) EXCEPT for one in my Google Sheet. I need some help. Thanks.

function myFunction() {

var sheet = SpreadsheetApp.getActiveSheet();

var cell = sheet.getRange("B4");

var refresh = parseInt(cell.getValue().toString()); var increment = refresh + 1;

cell.setValue(increment); }

1

1 Answers

0
votes

Assuming that your script gives you what you expect

All sheets :

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  ss.getSheets().forEach(function (sheet){
    var cell = sheet.getRange("B4");
    var refresh = parseInt(cell.getValue().toString()); 
    var increment = refresh + 1;
    cell.setValue(increment);
  })
}

All sheets except a list (Edit by Cooper)

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  const exclA = ['Sheet1','Sheet2'];//excluded sheets
  ss.getSheets().filter(sh => {!~exclA.indexOf(sh.getName())}).forEach(function (sheet){
    var cell = sheet.getRange("B4");
    var refresh = parseInt(cell.getValue().toString()); 
    var increment = refresh + 1;
    cell.setValue(increment);
  })
}

bitwise not