How To Run A Menu Item Script Across Selected Sheet Tabs
I have been trying to accomplish running this border script across only certain sheet tabs, and I have been unsuccessful at calling this across them. the sheet tabs are as follows.
Solution 1:
Revision 5
The "fix" didn't work because the code has nested for
s, both iterating through all sheets. The inner for has the suggested condition but the outer for not.
Revision 1
To limit the execution certain parts of the code to specific spreadsheet you could use the getName()
method of Class Sheet and compare it with the list of the valid sheets. One way of doing this is creating an array of the valid sheet names an use indexOf
.
Let say that the valid sheet names are Sheet1 and Sheet3, and that sheets
is a collection of all the sheets resulting from something like var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
), then the following code will iterate over all the sheets, but only execute one part of the code on the valid sheets:
for(var i = 0; i < sheets.length; i++)
if(['Sheet1','Sheet3'].indexOf(sheets[i].getName())){
//Add here the code to be executed on the valid sheets
}
}
Post a Comment for "How To Run A Menu Item Script Across Selected Sheet Tabs"