I have been trying to piece together some code for a task at work using Google sheetsSheets and I am having some issues with what I can find versus my current knowledge level. I am trying to create a script that will collect responses from a Form, move them to the last row of a separate sheet, and then clear the row.
function onEdit(event) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Form Responses 2" && r.getColumn() == 1 && r.getValue() > 0) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("TestEnd");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);
}
}
This code works only when manually changing the data in column A
but does not work when data is submitted via the Form response. I would greatly appreciate any help that is offered.