I have been messing around to build a google worksheet with script. So basically, in this file whenever there is input on column 1 and 4, there will be a timestamp shown in the next cell. And when the input is removed, the timestamp is clear. Everything runs fine so far, however as some weird issue happen. If instead of input in column 1 & 4, I paste values to the range, no timestamp appear or if I paste with the timestamp, the pasted timestamp will disappear. I don't know what happened or if you are clear on what I'm trying to ask. Anyway, here the script I'm using:
function onEdit(e) {
var s = SpreadsheetApp.getActiveSheet();
var r = e.range;
var nextCell = r.offset(0, 1);
if( s.getName() == "Nhap" && (r.getColumn() == 1 || r.getColumn() == 3) ){
if( nextCell.getValue() === '' && e.value !=null)
{
var time = Utilities.formatDate(new Date(), "GMT+7", "MM/dd/yyyy HH:mm:ss");
nextCell.setValue(time);
}
else{ nextCell.clearContent()}
};
}
Thanks