6

How can I automatically create and name new sheets in a Google Spreadsheet from a list of names which are being input in the sheet from a Google Form? I would like each new sheet to be created when a new name is added from the form. The new sheets should in the same spreadsheet.

This should all be done automatically whenever a new name is added in the form.

1 Answer 1

5

This can be done with a script. Enter the following in Script Editor, found under Tools. Change the 'Name' to whatever is the name of the form field that should be used.

function formSheet(e) {
  var sheetName = e.namedValues['Name'][0];
  var sheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet(sheetName);
  sheet.getRange(1, 1, 1, e.values.length).setValues([e.values]);
}

Then set a trigger using "Resources -> current project's triggers" in the menu. It should be "from spreadsheet", "on form submit".

This function also copies the submitted value to the first row of the new sheet.

Note: there cannot be two sheets with the same name, so if some name is submitted more than once, sheet creation will fail.

References: Event object, Sheet class methods.

1
  • current project's triggers seems to have moved to the edit menu. Commented Apr 14, 2020 at 11:14

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