How to use on Edit function twice in same spreadsheet

Viewed 7

I have below scripts which im trying to do an onEdit function for cell 1 when entered it enters the date on cell 30 and also the same function again when cell 20 is entered i get the date in cell 31.

However this is not working it only runs the last function to populate date in cell 31, how do i get around this to populate 2 dates when 2 different cells are entered.

function onEdit(e) {

  var row = e.range.getRow();
  var col = e.range.getColumn();

if(col === 1 && row > 1 && e.source.getActiveSheet().getName() === "BOM" ){

  e.source.getActiveSheet().getRange(row,30).setValue(new Date());
 
}

}


function onEdit(e) {

  var row = e.range.getRow();
  var col = e.range.getColumn();

if(col === 20 && row > 1 && e.source.getActiveSheet().getName() === "BOM" ){

  e.source.getActiveSheet().getRange(row,31).setValue(new Date());
 
}

}
0 Answers
Related