manniru
10/29/2016 - 5:01 PM

Google Spreadsheet scripts

Google Spreadsheet scripts

// Reference: http://webapps.stackexchange.com/a/31942
function onEdit() {
 var s = SpreadsheetApp.getActiveSheet();
 if( s.getName() == "Data" ) { //checks that we're on the correct sheet
   var r = s.getActiveCell();
   var last = s.getLastColumn() - r.getColumn();
   var nextCell = r.offset(0, last);
       var time = new Date();
       time = Utilities.formatDate(time, "GMT", "dd-MM-yyyy");
       nextCell.setValue(time);
 };
}

// http://stackoverflow.com/a/15863007
// http://webapps.stackexchange.com/a/25570
function onOpen() {
  var s = SpreadsheetApp.getActiveSheet();
  if( s.getName() == "Data" ) { //checks that we're on the correct sheet
    // // assumes headers in row 2
    var range = s.getRange(3, 1, s.getLastRow()-2, s.getLastColumn());
    range.sort({column: 13, ascending: false});
  }
}