i got a little problem with my code: i got 3 pieces of code, but i can’t combine it together.
All three codes put timestamps in different cells when certain cells change.
If I change cell A1, then in cell B1 insert timestamp. If the change in cell A2, then in cell B2 insert timestamp , etc.
Can you help me? Thanks.
1)
function onEdit(event) {
var tsheet = 'Заявки' ;
var lcol = 17;
var rcol = 17;
var tcol = 18;
var s = event.source.getActiveSheet();
var sname = s.getName();
if (sname == tsheet) {
var r = event.source.getActiveRange();
var scol = r.getColumn();
if (scol >= lcol && scol <= rcol) {
s.getRange(r.getRow(), tcol).setValue(new Date());
}
}
}
2)
function onEdit(event) {
var tsheet = 'Заявки' ;
var lcol = 15;
var rcol = 15;
var tcol = 16;
var s = event.source.getActiveSheet();
var sname = s.getName();
if (sname == tsheet) {
var r = event.source.getActiveRange();
var scol = r.getColumn();
if (scol >= lcol && scol <= rcol) {
s.getRange(r.getRow(), tcol).setValue(new Date());
}
}
}
3)
function onEdit(event) {
var tsheet = 'Заявки' ;
var lcol = 9;
var rcol = 9;
var tcol = 8;
var s = event.source.getActiveSheet();
var sname = s.getName();
if (sname == tsheet) {
var r = event.source.getActiveRange();
var scol = r.getColumn();
if (scol >= lcol && scol <= rcol) {
s.getRange(r.getRow(), tcol).setValue(new Date());
}
}
}
Put the column specification in an array: