Home > Blockchain >  Reverse sort data in Google Sheet
Reverse sort data in Google Sheet

Time:06-24

Google Forms linked to Google Sheets record submissions oldest to newest. We must scroll to the bottom of the sheet for the newest submission. I'd like to reverse that behavior so the newest submissions are at the top and oldest at the bottom. What is the best way to do this?

CodePudding user response:

Try (put a trigger on onFormSubmit)

function onFormSubmit(e) {
  var sheet = SpreadsheetApp.getActiveSheet();
  var row = sheet.getActiveRange().getRow();
  var column = e.values.length   1;
  var range = sheet.getRange(2, 1, row-1, column);
  range.sort({column: 1, ascending: false});
}
  • Related