Is there a function to reorder the tabs in Google Sheets? We'd like to arrange them on a specific value obtained on each of them,
/** ... */
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Store all the worksheets in this array
var sheetNameArray = [];
var sheets = ss.getSheets();
for (var i = 0; i < sheets.length; i++) {
z = sheets[i].getRange(3, 5);
z = z.getValue();
sheetNameArray.push(z);
}
/** Use value in array to reorder sheets */
You want to reorder the sheets in the opened spreadsheet using the sheet names in
sheetNameArray
. If my understanding is correct, how about this sample script? This sample script reorders sheets in the opened spreadsheet usingmoveActiveSheet()
.Sample script :
Note :
sheetNameArray
.sheetNameArray
are required to be included in the opened spreadsheet.sheetNameArray
is required to be the same with the length ofvar sheets = ss.getSheets();
.Reference :
If I misunderstand your question, I'm sorry.