I have created a new sheet for every new name entered in the form using the following code.

function formSheet(e) {
  var sheetName = e.namedValues['Name'][0];

You can find the details regarding the code in Auto-create and name new sheet in Google sheets from names being filled from a google form

Can I copy data while I make new sheet? I want to copy respective name data to its respective sheet as well. There can be multiple entries with the same name as well which should also be copied.

  • The main heads(name of the columns) of the sheet should also remain same for every sheet.
    – fb.junks
    Jun 13, 2016 at 5:50

1 Answer 1


I have expanded the functionality of the script from the linked question accordingly. First it checks whether the sheet with given name already exists. If it doesn't, the sheet is created and the headers of the form responses sheet are copied there. Otherwise, the existing sheet it used. Either way, the newly submitted data is then copied to the sheet.

function copyData(e) {
  var sheetName = e.namedValues['Name'][0];
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(sheetName);
  if (!sheet) {
    sheet = ss.insertSheet(sheetName);
    var formSheet = e.range.getSheet();
    var headers = formSheet.getRange(1, 1, 1, formSheet.getLastColumn());
    headers.copyTo(sheet.getRange(1, 1));

The function must be equipped with a trigger using "Resources -> current project's triggers" in the Script Editor menu: the trigger options are "from spreadsheet", "on form submit".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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