Im looking to make 60+ copies of a template spreadsheet using the google sheets API. I would like to be able to name each sheet using a cell in that same sheet.
function NewBracket() {
var spreadsheet = SpreadsheetApp.getActive();
var name = spreadsheet.getActiveRange().activate() ;
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Template'), true);
spreadsheet.duplicateActiveSheet();
spreadsheet.getRange('B1').activate();
name.copyTo(spreadsheet.getActiveRange(),SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
spreadsheet.getActiveSheet().setName(name);
};
When I run this, the sheet is created properly, the cell B1 is named properly, but the newly created sheet is named Range, not the name that is input into cell B1. How do I get the above code to name the sheet the same name that shows up in the B1 cell?
spreadsheet.getActiveSheet().setName(name.getValue());
– ra89fi