In column A I have a value added each day from the tab/cell TOTAL/A1 by this script:

function dailyLog() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName('TOTAL');
  var logSheet = ss.getSheetByName('TOTAL DIAGRAM');
  var lastRow = logSheet.getLastRow();
  // logSheet.getRange(lastRow + 1, 1).setValue(new Date());  // insert timestamp on the row below
  var range = sourceSheet.getDataRange();
  range.copyTo(logSheet.getRange(lastRow + 1, 1), {contentsOnly: true});

What I want is to have the date when it was added and I try to achieve that with the script:

function onEdit(e) {
  if (e.range.getSheet().getSheetName() == 'TOTAL CHAR' && e.range.getColumn() == 1) {
    e.range.offset(0,1).setValue(e.value.length>0 ? new Date() : '');

But it is only adding a date when I manually put a value in a cell. If the script is adding a value there is no date added.

Can this be done in any other way, or can Script 1 add the date to a cell to the right if the added value, as it is today it is added below?

1 Answer 1


On edit triggers are triggered only by manual changes.

If you already are using a script to paste data by using the copyTo method, use that script to add the date of when the data was copied.

Among many ways to do this, maybe you could found the offset method handy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.