As a beginner in coding Scripts, I have successfully managed to modify a script that adds a custom timestamp onEdit. It inserts the timestamp into the cell next to where the edit occurred, targeting columns 3 and 6 with an offset of -1.
The workbook now consists of multiple sheets, but the current script is not suitable for all of them. I am struggling to specify which sheets it should run on.
I have put together the following script, which works across all sheets, but I now need to limit it to specific sheets:
function onEdit(e) {
var colsToWatch = [3,6],
offset = [-1,-1],
ind = colsToWatch.indexOf(e.range.columnStart);
if (ind === -1 || e.range.rowStart === 1) return;
e.range.offset(0, offset[ind])
.setValue(!e.value ? null : Utilities.formatDate(new Date(), "GMT+1", "dd MMM yyyy HH:mm.ss"))
}
I would greatly appreciate if someone could provide me with the code to enable the script to only run on specific sheets. Additionally, suggestions for a simpler script that achieves the same objective, without overwriting the timestamp if the cell is edited again, would be very helpful.
Thank you so much!