Get the code:
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Clone Menu')
.addItem('Clone Sheet', 'cloneGoogleSheet')
.addSeparator()
.addToUi();
}
function cloneGoogleSheet() {
var source = SpreadsheetApp.getActiveSpreadsheet();
var sheet = source.getSheetByName('Sheet1');
//get sheet names
var ss_names = source.getSheetByName('SheetNames');
var ss_last_row = ss_names.getLastRow();
console.log('Row ' + ss_last_row );
for (let i = 0; i < ss_last_row; i++)
{
var row_id = i+1;
var get_sheet_name = ss_names.getRange("A"+ row_id).getValue();
console.log(get_sheet_name);
/* Before cloning the sheet, delete any previous copy */
var old = source.getSheetByName(get_sheet_name);
if (old) source.deleteSheet(old); // or old.setName(new Name);
/* Make the new sheet */
if(get_sheet_name != "Names")
{
sheet.copyTo(source).setName(get_sheet_name);
}
}
}