3

Been looking around for a solution to this for a while and not finding anything that works, unfortunately. I have tried copying and pasting several bits of code but cannot get my sales pipeline sheet to automatically sort on edit of a date field.

The link below is to a test sheet which should give an idea as to how I have formatted my sheet:

https://docs.google.com/a/trinitymirror.com/spreadsheets/d/1huTvgwfmh0RM0kz4BUEuYFZm7DwBG-69D8jTfps3IPg/edit?usp=sharing

I want to sort by Column G with the most recent dates at the bottom of the sheet.

Any suggestions welcome!

Thank you in advance for your help.

Simon Flavin
  • 33
  • 1
  • 1
  • 3

1 Answers1

5

this should help?

function onEdit(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheetByName("Sheet1")
  var range = sheet.getRange("A2:Z450");

 // Sorts by the values in column 2 (B)
 range.sort({column: 2, ascending: false});
  
}
OblongMedulla
  • 1,305
  • 8
  • 19