Reputation: 25
I have the below script I am trying to use to insert a timestamp when a value is input on a workbook I have. I have a few sheets in this workbook and it seems to only be working on one sheet. I'm not anywhere near a pro with Apps Scripts, so if someone can point me in the right direction I would appreciate it.
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Assignments" ) {
var r = s.getActiveCell();
if( r.getColumn() == 6 ) {
var nextCell = r.offset(0, 3);
if( nextCell.getValue() === '' )
nextCell.setValue(new Date());
}
}
}
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "IMEI Swap" ) {
var r = s.getActiveCell();
if( r.getColumn() == 6 ) {
var nextCell = r.offset(0, 3);
if( nextCell.getValue() === '' )
nextCell.setValue(new Date());
}
}
}
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Cancelations" ) {
var r = s.getActiveCell();
if( r.getColumn() == 6 ) {
var nextCell = r.offset(0, 3);
if( nextCell.getValue() === '' )
nextCell.setValue(new Date());
}
}
}
Upvotes: 0
Views: 37
Reputation: 64100
function onEdit(e) {
const sh = e.range.getSheet();
const shts = ["Assignments","IMEI Swap","Cancellations"];
if (~shts.indexOf(sh.getName()) && e.range.columnStart == 6 && e.range.offset(0, 3) === '') {
e.range.offset(0, 3).setValue(new Date());
}
}
Upvotes: 1