Is there a way to add a new sheet to a spreadsheet from a template? If I'm using a template for time, I'd like to add a new sheet from the same template every two weeks.


Yes, using the sheet.copyTo(destination) method. In the spreadsheet where you want to add the new sheets:

function copyFromTemplate(){
  var templateSpreadsheet = SpreadsheetApp.openById(TEMPLATE_ID);
  var template = templateSpreadsheet.getSheets()[0]; //Assuming it is the first sheet

  //The default name will be "Copy of [original name]". We can use today's date to rename it
  var today = (new Date()).toDateString();

  var currentSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();

You can set up a time-driven trigger for every week, or set up two monthly triggers to run the function every two weeks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.