回答編集履歴
1
こめんとでもつけてみるか
    
        answer	
    CHANGED
    
    | @@ -16,19 +16,19 @@ | |
| 16 16 | 
             
              const curSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
         | 
| 17 17 | 
             
              const templateSheet = curSpreadsheet.getSheetByName("Aシート");
         | 
| 18 18 | 
             
              const copyList = curSpreadsheet.getSheetByName("Bシート").getDataRange().getValues();
         | 
| 19 | 
            -
              copyList.shift();
         | 
| 19 | 
            +
              copyList.shift(); //ヘッダ行を捨てる
         | 
| 20 | 
            -
              copyList.forEach(function(element, index, array){
         | 
| 20 | 
            +
              copyList.forEach(function(element, index, array){ //forEachでループ。elementが1行分
         | 
| 21 | 
            -
                const fileName = element[0];
         | 
| 21 | 
            +
                const fileName = element[0]; // A列にファイル名
         | 
| 22 22 | 
             
                const file = SpreadsheetApp.create(fileName);
         | 
| 23 | 
            -
                const users  = element.slice(1).filter(String);
         | 
| 23 | 
            +
                const users  = element.slice(1).filter(String); // B列以降で文字になるやつだけフィルタ
         | 
| 24 24 | 
             
                file.addEditors(users);
         | 
| 25 | 
            -
                const copied = templateSheet.copyTo(file);
         | 
| 25 | 
            +
                const copied = templateSheet.copyTo(file); //copyToすると、コピーしたシートが返り値になる
         | 
| 26 | 
            -
                copied.setName("Aシート");
         | 
| 26 | 
            +
                copied.setName("Aシート"); //デフォルトで「Aシートのコピー」とかになるのでリネーム
         | 
| 27 27 | 
             
                trimSheet(file, "Aシート");
         | 
| 28 28 | 
             
              });
         | 
| 29 29 | 
             
            }
         | 
| 30 30 |  | 
| 31 | 
            -
            function trimSheet(spreadsheet, name) {
         | 
| 31 | 
            +
            function trimSheet(spreadsheet, name) { //スプレッドシートを作ると「シート1」ができちゃうので、指定した名前(name)を持たないシートを消すやつ
         | 
| 32 32 | 
             
              spreadsheet.getSheets().filter(function(sheet){ return sheet.getName().indexOf(name) === -1}).forEach(function(sheet){spreadsheet.deleteSheet(sheet);});
         | 
| 33 33 | 
             
            }
         | 
| 34 34 | 
             
            ```
         | 
