Logging Data Changes Track Data Changes in Google Sheets with Apps Script

Track and log changes in your Google Sheets data. Here’s how:

Step-by-Step Guide:

  1. Open the Script Editor:
    • Navigate to Extensions > Apps Script.
  2. Write the Logging Script:

function onEdit(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = e.range;
var newValue = e.value;
var oldValue = e.oldValue;
var logSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘Log’);
logSheet.appendRow([new Date(), range.getA1Notation(), oldValue, newValue]);
}

  1. Create a Log Sheet:
    • Add a new sheet named “Log” to your spreadsheet.

Explanation:

  • onEdit Trigger: Logs changes whenever data is edited in the sheet.