I have this script that works perfectly for any edit on the spreadsheet page:
function onEdit(e) {
if (!e.value) return;
e.source.getActiveSheet()
.getRange('F29')
.setValue(new Date());
}
However, when I try to modify it so that it only works with edits made to cell C29 (which is actually C29:E29 merged; I don't know if that matters), it won't update when there are edits made to that cell:
function onEdit(e) {
if (!e.value) return;
e.source.getCell('CONTENTS','C29:E29')
.getRange('F29')
.setValue(new Date());
}
I've tried it with both C29 & C29:E29 for getCell; neither works, so there's obviously something wrong and I'm out of ideas for how to make it work correctly. I'm sure there's an easy answer though...
@Rubén - this is the change I tried:
function onEdit(e) {
if (!e.value) return;
e.range.getA1Notation() === 'C29'
.getRange('F29')
.setValue(new Date());
}
I also tried this just in case it was an issue with the merged cells:
function onEdit(e) {
if (!e.value) return;
e.range.getA1Notation() === 'C29:E29'
.getRange('F29')
.setValue(new Date());
}
if
,switch
among other JavaScript control statements." – Rubén♦ Jul 24 '18 at 16:50