I have a functioning script working within Google Sheets. The document has multiple sheets. As such, I wish to be able to have one script that is capable of automating a time stamp on all of the sheets.
I have managed to get the script running on all sheets... however I wish to be able to have two separate variable columns and have them act independently of each other. For instance, var cols would affect SHEET 1 and var colx would affect SHEET 2. Would this be possible?
function onEdit(e) {
var s = e.source.getActiveSheet().getName();
var cols = [8];
var colx = [4, 9, 14];
var curDate = Utilities.formatDate(new Date(), "GMT-5", "M/d HH:mm:ss ")
var r = e.source.getActiveRange();
if (s !== "SHEET 1" && s !== 'SHEET 2' && s !== 'SHEET 3'|| cols.indexOf(e.range.columnStart) ==-1 && colx.indexOf(e.range.columnStart) ==-1||
!e.range.getValue()) return;
e.range.offset(0,1).setValue(curDate);
};
Novice scripter here, thanks for your patience. I was thinking that it would involve specifying the Sheet names with var cols and var colx but am unsure if this is the right approach.
Thanks in advance for any help!!!!!