I have three columns in a spreadsheet - Code(A), Status(B), Timestamp(C). (not actual structure, I just gave it as an example to illustrate the problem)
The cells in the Status column have a formula in them that changes the displayed text based on values from the Code column (ex. =IF(A1="01", "Paid", "Not paid")).
My aim is to have the script automatically insert a Timestamp in C when the status of a cell changes to "Paid".
The first code I tried was this:
function onEdit(e) {
var range = e.range;
var sheet = range.getSheet();
var eRow = range.getRowIndex();
var eColumn = range.getColumnIndex();
var value = range.getValue();
let mCell = sheet.getRange(eRow,eColumn+1);
const date = new Date();
if(eRow>1 && eColumn == 2 && sheet.getName() == "Sheet4" && value == "Plătit" ){
mCell.setValue(date);
}
}
However, I realized that this worked only if the text "Platit" was manually inserted in a cell, and not if the value displayed in that cell changed as an effect of a formula in it.
I've found no solutions to what I am attempting - how can I make the timestamp be added whenever the displayed value changes to a certain string?
Thank you for your help,
Catalin