function onEdit(e) {
var sheetName = "Sheet1"; // Specify the name of the sheet to track changes
var editedSheet = e.source.getActiveSheet();
if (editedSheet.getName() !== sheetName) {
return; // Exit the function if the edited sheet is not "Sheet1"
}
var range = e.range;
var user = Session.getActiveUser().getEmail();
var timestamp = new Date();
var oldValue = e.oldValue;
var newValue = e.value;
var cellReference = range.getA1Notation();
var logSheet = e.source.getSheetByName('ChangeLog'); // Replace 'ChangeLog' with your log sheet name
if (!logSheet) {
logSheet = e.source.insertSheet('ChangeLog');
logSheet.appendRow(['Timestamp', 'User', 'Cell Reference', 'Old Value', 'New Value']);
}
logSheet.appendRow([timestamp, user, cellReference, oldValue, newValue]);
}
Need help turning this logger to account for ranged changes As of now it does log changes but no info is logged for OLD Value and New Value if ranged changes were made.
this works for individual cell changes. Not for ranged changes(multiple cells changed at the same time)
Hoping for improvement to log ranged changes as multiple individual log per cell reference.
Hoping to add "Data was Deleted"(red Font) if data was deleted instead of just a blank for New Value.
Please add If Cell Value is Empty and new Value is empty Ignore. as deleted empty cells are logged still.
copying a cell from Sheet1 and Pasting to sheet1 is are showing as blanks for old and new value when logged. Hoping this can be done for ranged changes as well.
This should record on a per cell change. OLD value and new value.
thanks for the help