I wrote a simple script to automatically sort new input in various sheets, but I would like to exclude the two first sheets. Here's my script:
function onEdit(){
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var editedCell = sh.getActiveRange().getColumnIndex();
if(editedCell == 2) {
var range = sh.getRange("A3:P20");
range.sort({column: 2});
}
}
So if I use .getActiveSheet() while working on the first two sheets, the script wil do it's job, but unwanted. Can I stop the script, put on pause? Thanks for a reply. Tony
This will keep you from using the first two sheets. You could also use their names because if you move them then the first two sheets will change. The function isOneOfTheFirstTwo is explained below:
The below function gets the array of all sheets from the spreadsheet and looks at the first two which are the first two sheets on the left side of the spreadsheet. If you move them then the first two sheets will change. Any way I look only and the first two and ask the question is sh.getName() == allSheets[i] if either of the first two answer yes then function returns true other wise it returns false. The loop doesn't go past the first two sheets.