'Timestamp Assistance (Copy Paste)

The below code works fine when I'm editing the relevant cell, however when data is pasted in the relevant cells the timestamp fails to appear...

Kindly assist

Code:

function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) 
var r = s.getActiveCell();
if( r.getColumn() == 9 ) 
var nextCell = r.offset(0,-8);
if( nextCell.getValue() === '' ) 
nextCell.setValue(new Date());
}
}
}


Solution 1:[1]

Got the resolution, we need to use on event...

function onEdit(e) {
  var s = e.source.getActiveSheet();
  var sName = s.getName();
  var ar = e.range;
  var row = ar.getRow();
  var arRows = ar.getNumRows()  
  if( ar.getColumn() == 3 && sName == 'Sheet1') { 
      s.getRange(row,6,arRows).setValue(new  ate()).setNumberFormat("MM/dd/yyyy hh:mm");

} }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Holy Chowla