TriggerShelf

Recipe

Add a timestamp when a row is edited in Google Sheets

Trigger: Simple onEditServices: SpreadsheetApp, UtilitiesMock-tested: Nov 2026

Whenever a cell in columns A to C changes, the current date and time is written to column D of the same row, in the spreadsheet's own time zone.

Set it up

  1. Open the sheet, then Extensions > Apps Script. Paste the script and save.
  2. Edit a cell in A, B or C on Sheet1. Column D fills in.
  3. No trigger setup is needed. Change TS if your columns or tab name differ.

The script

/**
 * Stamp the date and time in column D when a cell in A-C changes.
 * Simple trigger: runs as soon as it is saved, no setup.
 */
var TS = { sheetName: 'Sheet1', watchFrom: 1, watchTo: 3, stampCol: 4, format: 'yyyy-MM-dd HH:mm' };

function onEdit(e) {
  if (!e || !e.range) return 'skip:no-event';
  var range = e.range;
  var sheet = range.getSheet();
  if (sheet.getName() !== TS.sheetName || range.getRow() < 2) return 'skip';
  if (range.getColumn() > TS.watchTo || range.getColumn() + range.getNumColumns() - 1 < TS.watchFrom) return 'skip';
  var tz = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone();
  var stamp = Utilities.formatDate(new Date(), tz, TS.format);
  for (var r = 0; r < range.getNumRows(); r++) {
    sheet.getRange(range.getRow() + r, TS.stampCol).setValue(stamp);
  }
  return 'stamped';
}
Test status. 4 of 4 automated checks pass, run Nov 2026 against simulated Google services. This recipe has not yet been run inside a live Google account. Test it on a copy of your sheet first.

What you should see

ItemQtyNoteEdited
Pens40Reorder2026-11-14 09:41
Tape12

Edit B2 and D2 fills in. Sample values, not output from a real account.

Common errors and fixes

Nothing happens
The function must be named exactly onEdit, and TS.sheetName must match the tab.
The timestamp is in the wrong time zone
The script reads the spreadsheet time zone. Set it in File > Settings.
TypeError: Cannot read properties of undefined (reading 'range')
You ran onEdit from the editor. It only works when a cell edit fires it.

Permissions. Running this script asks you to grant Google permissions for the services listed above, to your own script. TriggerShelf never receives your Google data. See the permissions table. Google will show "Google hasn't verified this app"; that is expected for a script you paste yourself.