Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move sheet within Google Spreadsheeet using apps script [duplicate]

I want to move a sheet within the spreadsheeet using apps script. How to do it?

Best live!

like image 452
contributorpw Avatar asked May 06 '13 15:05

contributorpw


People also ask

How do you duplicate a sheet in Google Sheets using a script?

To duplicate a sheet:Click the tab of the sheet you want to duplicate, then select Duplicate from the menu that appears. A duplicate of the sheet will appear in the sheets toolbar. It will be named as a copy of the original sheet, such as Copy of May. If you want, you can rename the sheet.

How do you rearrange sheets in Google Sheets?

Sort an entire sheet On your computer, open a spreadsheet in Google Sheets. At the top, right-click the letter of the column you want to sort by. Click Sort sheet A to Z or Sort sheet Z to A.


1 Answers

Have you looked at the documentation ?

It does show an example as well :

 // This example assumes there are two sheets in the current
 // active spreadsheet: one named "first", and another named "second",
 // and that the current active sheet (first) is in position 1
 var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = spreadsheet.getSheetByName("first");

 // This should output 'Current index of sheet: 1'
 Logger.log("Current index of sheet: %s", sheet.getIndex());

 spreadsheet.moveActiveSheet(2);

 // This should output 'New index of sheet: 2'
 Logger.log("New index of sheet: %s", sheet.getIndex());
like image 108
Serge insas Avatar answered Sep 24 '22 00:09

Serge insas