1

I am trying to run all three of these in any order but only the third runs:

1.

function onEdit(){
  var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var editedCell = sh.getActiveRange().getColumnIndex();

  if(editedCell == 10) { 
    var range = sh.getRange("A:O");
    range.sort([{column: 1}, {column: 14, ascending: true}, {column: 5, ascending: false}]);
  }
}

2.

function onEdit() {
  var sheetName = "PRE-APPRAISAL";
  var s = SpreadsheetApp.getActiveSheet();
  if (s.getName() !== sheetName) return;
  var r = s.getActiveCell();
  if( r.getColumn() != 'J' ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT-08:00", "MM/dd/yy, hh:mm");
    SpreadsheetApp.getActiveSheet().getRange('H' + row.toString()).setValue(time);}
  }

3.

function onEdit() {
  var sheetName = "POST-APPRAISAL";
  var s = SpreadsheetApp.getActiveSheet();
  if (s.getName() !== sheetName) return;
  var r = s.getActiveCell();
  if( r.getColumn() != 'J' ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT-08:00", "MM/dd/yy, hh:mm");
    SpreadsheetApp.getActiveSheet().getRange('H' + row.toString()).setValue(time);}
  }
1

That occurs because only could be one function called onEdit() by Google Apps Script Project.

Change their names to myFunction1, myFunction2, myFuntion3 or anything else but using an unique name for each function, then make an onEdit() function that calls them, something like the following:

function onEdit(){
  myFunction1();
  myFunction2();
  myFunction3();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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