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);
}
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With