I've got a script that sorts a Google Spreadsheet when a value in a column is changed.

I'd like to add to the script the following functionality:

If the value for column E = "Complete" then the entire row is moved to a different spreadsheet (that is a different tab in the same Google Spreadsheet document).

The row would either be inserted, or appended to the bottom of the spreadsheet in the first blank row.

Is this possible?


1 Answer 1


Yes, I currently do this for a form system once it receives all necessary approvals I move all of the form submission's values to a new sheet that only contains approved submissions.

The following code gets the values of the row you would like to move and copies it (maintaining the original row) to the destination sheet. Assume that the submissionrow variable is the index of the row you want to move and the sheet variable is the source sheet you are checking the values on.

var lastcol = sheet.getLastColumn();
var rowvalues = sheet.getRange(submissionrow,1,1,lastcol).getValues();
var destinationsheet = SpreadsheetApp.openById(spreadsheetId).getSheetByName(nameofthedestinationsheet);
var rownum = destinationsheet.getLastRow() + 1;
destinationsheet.getRange(rownum, 1,1,lastcol).setValues(rowvalues);

Your Answer

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

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