I’m using this code to timestamp sheet named "Verify"’s Col11 based on the first time (only) Col9 is edited. It will be cleared and reset manually, daily.
The issue i’m having is editing Col9 on any sheet makes Col11 on the "Verify" tab timestamped, on the corresponding row that was edited on another sheet. Example, i’ll edit Col9 on "Example Sheet"’s row 89, and Col11 row 89 on sheet "Verify" is timestamped. I’ll attach the code i’m using below – thank you!
function onEdit(e) {
var sh = e.source.getSheetByName("Verify");
var row = e.range.getRow();
var col = e.range.getColumn();
var stampCol = sh.getRange(row, 11);
if (col == 9 && !stampCol.getValue()) {
var tz = e.source.getSpreadsheetTimeZone();
var date = Utilities.formatDate(new Date(), tz, 'dd-MM-yyyy hh:mm:ss');
stampCol.setValue(date);
}
}
2
Answers
I think the issue is you are "hard coding" the sh var to reference the ‘Verify’ sheet. Combined with your IF statement that doesn’t specifically include a sheet name reference.
Try replacing
with:
And replacing:
with
Try this: