1

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!

2 Answers2

3

I think you would just be looking to modify your last line as follows:

    range.sort([{column: 10, ascending: true}, {column: 17, ascending: true}]);
LWC
  • 1,084
  • 1
  • 10
  • 28
GEOWill
  • 96
  • 4
0

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 :)

Community
  • 1
  • 1
cwatson1988
  • 106
  • 5
  • I saw that one but I wasn't sure how to add it to the script I already have in place. I would need some assistance (I'm a serious Novice at this) – Nikki Carter Aug 30 '16 at 16:16