3
votes

I'm trying to use copyTo to duplicate an entire sheet from one Google Sheet to a brand new one. Everything works great however, the newly created Sheets all say "Copy" and then the Sheet name. Is there a way to remove the word Copy? Code is below.

function setupSheet() 
{
var sources = SpreadsheetApp.openById('172teYmA4Bz61PscMQiTmpqWdvBUBDu_J2hR0m_8i_b8');
var allSheets = ['Display Case', 'Your Badges', 'Badge Directory', 'Activate Sheet'];

 allSheets.forEach(function(each) 
 {
  var thisSheet = SpreadsheetApp.getActive()
  var sourcevalues = sources.getSheetByName(each).copyTo(thisSheet)
 });
}
1

1 Answers

3
votes
var sourcevalues = 
sources.getSheetByName(each).copyTo(thisSheet).setName(each);