How To Sort Sheets in Google Sheets? – Arrange Sheets in Google Sheets

When you are working with a spreadsheet that has a large number of sheets, it is extremely difficult to find the particular sheet you are searching for among other sheets. To overcome this issue, we can simply sort the sheets. Google Sheets allows its users to sort the sheets using various methods. Also, with the help of Apps Scripts, one can also sort the Google Sheets in either ascending, descending, or even a random order. Thus, if you are looking for information on how to sort sheets in Google Sheets, then this page is for you. On this page, we have provided the various methods with the help of which you can sort sheets using Google Sheets Tips. Read further to find out more.

Table of Contents

How to Sort Multiple Sheets in Google Sheets?

As discussed above, there are various methods with the help of which one can easily sort the sheets on the spreadsheet. However, the best method to sort sheets in Google Sheets is the manual method. The manual method for sorting sheets in a spreadsheet is outlined below:

  • 1st Step: Open the Google Spreadsheet where you have multiple sheets.
  • 2nd Step: Now click on the sheet and hold the mouse button.
  • 3rd Step: If you want to move the sheet towards the right side, hover your mouse towards the right. If you want to sort the selected sheet towards the left, then hover your mouse and sort the sheet toward the left.

sort sheets in google sheets6

This is one of the easiest methods to sort the sheets in Google Sheets.

Sort Sheets Manually Using Right and Left Commands in Google Sheets

One can also easily sort the sheets in the spreadsheet using the right and left commands. The steps to get this done in Google Sheets are outlined below:

  • 1st Step: First, launch Google Sheets on your device.
  • 2nd Step: Click on the sheet and left click.
  • 3rd Step: In the Sheet drop-down menu, choose “Move right” to move the sheet towards the right.
  • 4th Step: To move your sheet towards the left, choose the “Move left” option.

This is the best way to move your sheets.

sort sheets in google sheets6

Sort Sheets in Google Sheets using App Scripts

While the above two methods are helpful, it is quite difficult for a user to sort sheets in the spreadsheet either in ascending, descending, or random order. Thus, we can simply use the Apps Scripts to create our own functions and sort sheets accordingly. The detailed steps on how to do this in Google Sheets are given below:

  • 1st Step: First, launch Google Sheets on your device.
  • 2nd Step: Click on the “Extensions” tab and choose “Apps Script” from the drop down menu.

sort sheets in google sheets6

  • 3rd Step: Now copy and paste the following code and click on the “Run” button.
function sortSheetsAsc() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheets = ss.getSheets();
 var sheetNameArray = [];
 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);
 }
}
function sortSheetsDesc() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheets = ss.getSheets();
 var sheetNameArray = [];
 for (var i = 0; i < sheets.length; i++) {
 sheetNameArray.push(sheets[i].getName());
 }
 sheetNameArray.sort().reverse();
 for( var j = 0; j < sheets.length; j++ ) {
 ss.setActiveSheet(ss.getSheetByName(sheetNameArray[j]));
 ss.moveActiveSheet(j + 1);
 }
}
function sortSheetsRandom() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheets = ss.getSheets();
 var sheetNameArray = [];
 for (var i = 0; i < sheets.length; i++) {
 sheetNameArray.push(sheets[i].getName());
 }
 sheetNameArray.sort().sort(() => (Math.random() > .5) ? 1 : -1);;
 for( var j = 0; j < sheets.length; j++ ) {
 ss.setActiveSheet(ss.getSheetByName(sheetNameArray[j]));
 ss.moveActiveSheet(j);
 }
}
function onOpen() {
 var spreadsheet = SpreadsheetApp.getActive();
 var menuItems = [
 {name: 'Sort Sheets A ➜ Z', functionName: 'sortSheetsAsc'},
 {name: 'Sort Sheets Z ➜ A', functionName: 'sortSheetsDesc'},
 {name: 'Randomize Sheet Order 🎲', functionName: 'sortSheetsRandom'}
 ];
 spreadsheet.addMenu('Sheet Tools', menuItems);
}

sort sheets in google sheets6

  • 4th Step: After the code has been executed successfully, navigate to the spreadsheet.
  • 5th Step: In the spreadsheet, check if the “Sheet Tools” tab has been created and has three options, namely – Sort Sheets A -> Z, Sort Sheets Z -> A, and Randomize Sheet order.

sort sheets in google sheets6

Explanation: 

Four functions make up this code.

  • Based on the sheet names, sortSheetsAsc will order all of the sheets from A to Z in ascending order.
  • Based on the sheet names, sortSheetsDesc will order all of the sheets from Z to A in descending order.
  • The order of the sheets will be randomized using sortSheetsRandom.
  • Every time you open this document, onOpen will automatically execute. It will add a new menu item to the main menu called Sheet Tools that will let you access the additional features from the UI.

For Sorting Sheets in Ascending Order

  1. Click on the tab “Sheets Tools“.
  2. Choose the option “Sort Sheets A–Z” and this will sort sheets in ascending order.

sort sheets in google sheets6

Sorting Sheets in Descending Order

  1. Click on the “Sheets Tools” tab from the menubar.
  2. Choose the option “Sort Sheets Z->A” and this will sort the sheets in the spreadsheet in descending order.

sort sheets in google sheets6

For Sorting Sheets in Random Order

  1. Click on the “Sheets Tools” tab from the menubar.
  2. Choose “Randomize Sheet Order” from the drop down and you will see the sheets in the spreadsheet arranged in random order.

sort sheets in google sheets6

Now that you are provided with all the necessary information on how to sort sheets in Google Sheets, With the help of the above-provided methods, one can easily sort the sheets on the spreadsheet. However, if you have a better way to arrange the sheets in Google Sheets, ping us through the comment box below.

Leave a Comment