Last active
October 23, 2023 01:23
-
-
Save chipoglesby/26fa70a35f0b420ffc23 to your computer and use it in GitHub Desktop.
Automatically move the sheets in a spreadsheet into alphabetical order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rwillman483 That should be possible. You would need get the value of each cell in each sheet, push that to an array and then sort it. Let me see if I can work up an example for you.