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); }
Assuming that your script gives you what you expect
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);
})
}
Edit by Cooper: Perehaps something like this:
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);
})
}
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.