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?