Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move copied sheet at the end of the spreadsheet?

How to move copied sheet (List) at the end of the spreadsheet?

 function makecopy() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName('List');
  var values = sourceSheet.copyTo(ss);
  }
like image 545
snoop31 Avatar asked Sep 17 '25 17:09

snoop31


1 Answers

moveActiveSheet is a method of the spreadsheet object

Here is an example :

function makecopy() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName('List');// you can get the sheet by its name or by its index
  var copy = sourceSheet.copyTo(ss);
  Logger.log(copy.getName());// optional, just to check the copy's name
  ss.setActiveSheet(copy);// set it active
  ss.moveActiveSheet(ss.getNumSheets());// move it to the last position
  }
like image 136
Serge insas Avatar answered Sep 19 '25 06:09

Serge insas