Is there a way that I can put the name that is in the roster in a specific cell in each google sheet?

Viewed 25

I'm making multiple duplicates of a Google sheet, rename the copied documents using a roster in another google sheet document, then move them all to a specified folder in my drive. Is there a way that I can put the name that is in the roster in a specific cell in each google sheet?

1 Answers

Make, Move and Save Name

function makeSheet() {
  const ss0 = SpreadsheetApp.getActive();
  const sh0 = ss0.getSheetByName("Roster");
  const list = sh0.getRange("A2:A" + sh0.getLastRow()).getValues().flat();
  const folder = DriveApp.getFolderById("folderid");
  list.forEach((name,i) => {
    let id = SpreadsheetApp.create(name).getId();
    SpreadsheetApp.openById(id).getSheets()[0].getRange("A1").setValue(name);
    let fi = DriveApp.getFileById(id);
    fi.moveTo(folder);
  })
}
Related