0

I have the following code to move an entire row based on a drop down menu, however, the code does not work for rows which are added to the sheet through a google form. Does anyone have any ideas why this might be happening?

The code I'm using is as follows:

function onEdit(e) {
  const src = e.source.getActiveSheet();
  const r = e.range;
  if (r.columnStart != 12 || r.rowStart == 1 ) return;
  const dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(e.value);
  src.getRange(r.rowStart,1,1,12).moveTo(dest.getRange(dest.getLastRow()+1,1,1,12));
  src.deleteRow(r.rowStart);
}

The sheet which I want to move the rows to is titled: "printed", and the dropdown menu to is in column L. The only available option in the drop down menu is "printed". Rows will be populated through a google form.

This is what the spreadsheet looks like

NSK
  • 1
  • 1
    Yes. onEdit trigger only fires on user edits – Cooper Dec 06 '21 at 15:52
  • `function onFormSubmit(e) { const dest = SpreadsheetApp.getActive().getSheetByName(e.values[11]); dest.getRange(dest.getLastRow()+1,1,1,e.values.length).setValues([e.values()]); } ` – Cooper Dec 06 '21 at 16:04
  • Hi, thanks for your answer. I've tried this but it doesn't seem to work. The dropdown would be altered by user edit after the form has submitted. It works on rows where data is inputted manually, but when the data comes from a form submission it doesn't move the row. – NSK Dec 07 '21 at 06:39
  • I think `[e.values()]` should have been `[e.values]` I don't know what I was thinking – Cooper Dec 07 '21 at 07:59

0 Answers0