Reputation: 11
I have multiple sheets that need sorting and they need to be sorted by different columns. This is the script I'm currently running:
function onEdit(){
var sheetNames = ["General Clerk Onboarding Tracker"];
var ss = SpreadsheetApp.getActiveSpreadsheet();
sheetNames.forEach(function(name) {
var sheet = ss.getSheetByName(name);
var range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
range.sort([{column: 10, ascending: true}]);
});
}
I want to add another range sort column so it'll sort by column 10 first, THEN by column 17. I can't seem to get it to auto-sort 2 columns. Any help would be appreciated!
Upvotes: 1
Views: 2608
Reputation: 96
I think you would just be looking to modify your last line as follows:
range.sort([{column: 10, ascending: true}, {column: 17, ascending: true}]);
Upvotes: 3
Reputation: 106
I think this might help Additional Sorting Rules have a look and if not I will have a further look into it for you. Good Luck :)
Upvotes: 0