For those considering improving googlesheets efficiency.
Those with many sheet tabs in one file.
Google Sheets is a very convenient tool, but a troublesome aspect is moving sheet tabs.
When there are many tabs, the basic method of moving them one by one can be time-consuming, especially when you want to move a tab from the far right to the far left. In such cases, you can use Google Apps Script to move them all at once.
If you need to repeatedly move sheet tabs to the far left, using Google Apps Script can make the process easier.
TOC
The script to move the selected sheet tab to the far left
// Move the selected sheet tab to the far leftfunctionmoveActiveSheetToLeft() {var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();var activeSheet = spreadsheet.getActiveSheet(); spreadsheet.moveActiveSheet(1);}
Here is the script to move the selected sheet tab to the far left.
You can easily copy the script by clicking the copy icon in the top right corner of the code block.
You can copy and use the script as it is.
The number in the fourth line of ‘moveActiveSheet(1)’ determines to which position the sheet will be moved. For example, if you want to move the sheet to the third position, change it to (3).
Script to move the selected sheet tab to the far right
// Move the selected sheet tab to the far rightfunctionmoveActiveSheetToRight() {var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();var totalSheets = spreadsheet.getNumSheets();var activeSheet = spreadsheet.getActiveSheet(); spreadsheet.moveActiveSheet(totalSheets);}
Here’s the script for moving the selected sheet to the far right, opposite to what we did earlier.
You can copy and use it as is.
How to Use the Script
スクリプトの使用方法
Toolbar – Extensions – Apps Script
Paste the script
Save the script
Run
The selected sheet tab moves to the left (right).
STEP
Select ‘Extensions – Apps Script’ from the toolbar.
Open the spreadsheet, then click on “Extensions” in the toolbar and select “Apps Script.”
STEP
Paste the script.
Since `function myFunction(){}` is already there at the beginning, delete it and paste the above script.
STEP
Press “Save Project”
STEP
Press “Run.”
If you’re running the script for the first time, you need to authorize it.
Therefore, press “Review Permissions.“
Next, press “Advanced.”
Press “Go to Untitled project (Unsafe).”
After that, press “Allow.”
STEP
When executed, the selected sheet tab moves to the far left.
In the image above, “Sheet 5” has moved to the far left.
If there are only a few sheets, you can move them easily without using Apps Script, but when there are many, using Apps Script can save you time.
Basic Method for Moving Sheet Tabs (Without Using Google Apps Script)
Drag & Drop Right-click Menu
Drag & Drop
Hover the cursor over the sheet tab you want to move.
Click and hold the sheet tab with the mouse.
Drag the sheet tab all the way to the left.
Release the sheet tab.
Right-click Menu
Right-click on the sheet tab you want to move.
Select “Move left” from the menu that appears.
When there are only a few sheet tabs, using drag and drop is an easy way to move them.
Summary
When there are many sheet tabs, it’s easier to use Google Apps Script to move them to the far left.
If there are only a few sheet tabs, it’s quicker to move them with drag and drop.
Move the sheet tab to the far left.
// Move the selected sheet tab to the far leftfunctionmoveActiveSheetToLeft() {var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();var activeSheet = spreadsheet.getActiveSheet(); spreadsheet.moveActiveSheet(1);}
シートタブを右端に移動させる
// Move the selected sheet tab to the far rightfunctionmoveActiveSheetToRight() {var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();var totalSheets = spreadsheet.getNumSheets();var activeSheet = spreadsheet.getActiveSheet(); spreadsheet.moveActiveSheet(totalSheets);}
Please use this function when you have many sheet tabs.
Our company offers support for improving work efficiency through the use of Google Apps Script. If you need assistance with Google Apps Script customization or error resolution, please feel free to contact us. We are fully committed to supporting your business improvements.
Comments