I have make an attempt to create this code and it is working fine but it writes the timestamp whenever Col"B"
any values changes to specific value.
I just want that when cell value changes from Approved
to Reject
then write timestamp.
It should not work when other values
changed to Reject
.
Any help will be appreciated.
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = e.source.getActiveSheet().getName();
var editedColumn = e.range.getSheet().getActiveCell().getColumn();
if(sheet=="Sheet1"){
if(e.value=="Approved" && editedColumn==2 ){
e.range.offset(0,12).setValue(new Date ()).setNumberFormat("MM/dd/yyyy hh:mm:ss");
}}}
CodePudding user response:
Instead of
e.value=="Approved" && editedColumn==2
use
e.oldValue=="Approved" && e.value=="Reject" && editedColumn==2
Resources