I'm trying out this bellow script in google app scripts. but I'm having some issues with the duplicate part. I want the "ORIGINAL" Sheet to be duplicated and renamed using cell G1. Sadly it fails at the duplicate part. If I comment out the duplicate code and run the code, the ORIGINAL sheet will just be renamed using the value on G1. How do I make it so when I run it, it duplicates the ORIGINAl sheet and renames the duplicated sheet with the value from G1?
function CreateNewPulseSheet() {
// The code below makes a duplicate of the active sheet
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ORIGINAL").activate(); //getSheetByName returns a Sheet, but doesn't set it as active
SpreadsheetApp.getActiveSpreadsheet.duplicateActiveSheet(); //Duplicate makes a copy and sets it as the active sheet
// The code below will rename the active sheet to a date based on cell M1 of the source spreadsheet
var myValue = SpreadsheetApp.getActiveSheet().getRange("G1").getDisplayValue();
SpreadsheetApp.getActiveSpreadsheet().renameActiveSheet(myValue);
}
CodePudding user response:
Replace
SpreadsheetApp.getActiveSpreadsheet.duplicateActiveSheet();
by
SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();