What I'm Learning: How to automatically sort sheets in a Google Spreadsheet Alphabetically

I love it when someone else figures these kinds of things out and then shares them.

function sortSheets () {  var ss = SpreadsheetApp.getActiveSpreadsheet();  var sheetNameArray = [];  var sheets = ss.getSheets();     for (var i = 0; i < sheets.length; i++) {    sheetNameArray.push(sheets[i].getName());  }    sheetNameArray.sort();      for( var j = 0; j < sheets.length; j++ ) {    ss.setActiveSheet(ss.getSheetByName(sheetNameArray[j]));    ss.moveActiveSheet(j + 1);  }}

Source: Re: Sorting (alphabetically or chronologically) “tabs” at the bottom of a SHEET – Google Product Forums

Leave a Reply

Your email address will not be published. Required fields are marked *