Reputation: 15
I have a Google Form that is connected to a Google Spreadsheet. I noticed that if I decide to manually write something on this Google Spreadsheet, the order of entry is not preserved during future responses.
For example: Assume there are 3 rows each with a Google Form response and I manually write something in the 4th row. The next time there is a Google Form response, the spreadsheet will show the new response in the 4th row, and move my manual input to the 5th row.
I was wondering if there was anyway to get the new responses to show up below any manual inputs so that the order is preserved. (Have 3 rows with Google form data, the 4th row with the manual input, and 5th row with the Google Form response.)
Upvotes: 0
Views: 874
Reputation: 5533
You can create an onFormSubmit Trigger that will check if there is a manual input in the spreadsheet by comparing the last row and the response row. If the response row is not equal to the last row, it means a manual input has been made and we move the response to the last row.
Go to Tools -> Script editor and paste the code below:
function moveToLastRow(e) {
var sheet = e.range.getSheet();
var lastRow = sheet.getLastRow();
var row = e.range.getRow();
var data = e.values;
if(lastRow != row){
sheet.deleteRow(row);
sheet.appendRow(data);
}
}
Create an onFormSubmit Trigger:
For this case, copy these configurations:
Output:
Upvotes: 1