Timestamp when a status changes
If column D is "Done", write the current date in column E on the same row. onEdit checks e.range.getColumn() and e.value before setting the timestamp.
The onEdit trigger runs a script automatically when someone changes a cell in your spreadsheet. It is one of the simplest ways to make Sheets react to user input without clicking a custom menu. You define the function in Apps Script and bind it to the onEdit event for that file.
Use onEdit when you need instant reactions to edits: stamping a last-updated time, validating input, copying a row to a log tab, or showing a warning when a status changes.
Skip onEdit for heavy work, bulk imports, or anything that must run when nobody is editing. Long-running scripts can slow the sheet or hit execution limits. Use time-based or installable triggers instead.
Open Extensions > Apps Script and create a function named onEdit or bind onEdit(e) in the script.
The event object e includes range, value, oldValue, and source so your code knows what changed.
Save the script and edit a cell in the sheet to test. Simple onEdit runs for any edit in the file.
For stricter control, use an installable onEdit trigger from the Triggers page in Apps Script.
{:"Keep the handler fast"=>"read e.range, branch on sheet name or column, then update only what you need."}
Add error handling and avoid infinite loops when your script writes back to the same range.
If column D is "Done", write the current date in column E on the same row. onEdit checks e.range.getColumn() and e.value before setting the timestamp.
When someone types in the Amount column, compare the value to a max in a Settings tab. If it is too high, clear the cell and show a Browser.msgBox warning.
Copy the edited row to a hidden Log tab with user email and timestamp from Session.getActiveUser().
Build this without starting from a blank cell
Use a Better Sheets tool for onEdit trigger, then watch a walkthrough when you want the full pattern.
Watch how onEdit trigger works
Guides that explain onEdit trigger in more depth.
Make your data tasks simpler & efficient. Discover the power of automation in Google Sheets with a comprehensive guide that covers everything from triggers to scripts.
Read post →Transferring Data Between Cells in Different Spreadsheets
Read post →Did you know you can actually code in Google Sheets?
Read post →Triggers tell Apps Script when to run a function: on edit, on open, on a schedule, or when a form is submitted. Simple triggers use reserved names like onEdit. Installable triggers are created in the Apps Script Triggers page and can do more, including running as a specific user or on a timer.
Read guide →The Script Editor is the Apps Script workspace inside your spreadsheet where you write JavaScript that talks to Sheets, Gmail, and other Google services. You open it from Extensions > Apps Script. Every function you save can be run manually, bound to a trigger, or linked from a custom menu.
Read guide →Automation means work happens without repeating the same clicks every day: imports update, emails send, rows move, and dashboards refresh. In Sheets, automation usually stacks built-in features, Apps Script, and sometimes the Sheets API or add-ons. Start with the lightest tool that still solves the job.
Read guide →A workflow is the path work takes through your sheet: intake, review, approval, done. Good workflows use consistent columns, statuses everyone understands, and just enough automation to move tasks forward without hiding steps from the team.
Read guide →Done reading about onEdit trigger?
Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.