I am new to coding/JavaScript, so I apologize in advance if this question is (unintentionally) poorly phrased. I've been searching around and found some similar questions but nothing to solve my issue.

I have a scenario where I have a Workbook with one sheet called "Data" containing records and a column header. There is another sheet called "Template" containing a fixed template. I need to duplicate the Template for the number of records in Data (i.e. 5 records of Data will create 4 copies of the original Template). Next, I need to add the first record in Data to a specific cell range in the original Template, the second record in Data to the same specific cell range in the first Template copy, etc.

I've gotten my script to where I can duplicate the Template sheet and pull all the records into an array, but I haven't been able to figure out how to set the first record to the original Template, the second record to the second Template, etc. Any help is greatly appreciated!

```
function duplicate() {

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data');

var startRow = 2; //first row
var lastRow = sheet.getLastRow();

var StartCol = 1
var LastCol = sheet.getLastColumn()

var numCol = sheet.getLastColumn();
var numRows = sheet.getLastRow(); // Number of rows to process

var dataRange = sheet.getRange(startRow, StartCol, numRows, numCol);
var data = dataRange.getValues(); 

//Duplicate Sheet based on # of Records 
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Template"); 
for (i=1;i<numRows;++i) s.copyTo(ss).setName("Template "+i);

//A bad attempt at trying to add the records to each template copy
var nextSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Template "+i);
nextSheet.getRange(lastRow+1,1,numRows,numCol).setValues(data[0+1]);
}

```

'