Is there a google spreadsheet function showing when a given cell was last updated?
- User
Is there a google spreadsheet function showing when a given cell was last updated?
- Assistant
Google Sheets does not have a built-in function that directly shows when a cell was last updated. By default, it only tracks file-level version history (File → Version history), not per-cell timestamps. That said, there are a few workarounds:
Option 1: Use Google Apps Script You can write a small script to automatically record the last modified timestamp of a cell into another column.
Go to Extensions → Apps Script.
Paste this code:
javascriptCopiar códigofunction onEdit(e) { var sheet = e.source.getActiveSheet(); var colToWatch = 1; // Column A var colToRecord = 2; // Column B
if (e.range.getColumn() == colToWatch) { var row = e.range.getRow(); sheet.getRange(row, colToRecord).setValue(new Date()); } }
👉 This will record the timestamp in column B whenever the value in column A is edited. You can adjust colToWatch and colToRecord to suit your needs.
- User
Do it on column w 5-37 and put date on r 5-37
- Assistant
Perfect — we’ll tweak the script so it only tracks edits in Column W (rows 5–37), and writes the timestamp in Column R (same row). Here’s the exact Google Apps Script you need: javascriptCopiar códigofunction onEdit(e) { var sheet = e.range.getSheet(); var colToWatch = 23; // Column W var colToRecord = 18; // Column R var row = e.range.getRow();
// Only act if edit is in Column W and between rows 5–37 if (e.range.getColumn() == colToWatch && row >= 5 && row <= 37) { sheet.getRange(row, colToRecord).setValue(new Date()); } }
How to add this:
In your Google Sheet, go to Extensions → Apps Script.
Delete any code there, paste the above, and save.
Close the Apps Script editor.
Now:
If you change a value in W5–W37, the corresponding cell in R5–R37 will automatically get a timestamp (date & time).
If you edit something outside that range, nothing happens.
👉 Do you want the timestamp to freeze (stay the same once written), or should it update every time the cell in W changes?
- User
If I run it, should it run? because running gives: 11:43:02 Error TypeError: Cannot read properties of undefined (reading 'range') onEdit @ Code.gs:15
- Assistant
Good question 👍 — that error happens because of how simple triggers work in Google Apps Script. The function onEdit(e) only works when you actually edit a cell in the sheet. If you try to press ▶ Run inside the Apps Script editor, the script has no e (event object), so e.range is undefined → that’s why you got the error. ✅ To test it properly:
Save the script.
Go back to your sheet.
Manually edit a value in W5–W37.
You should see the timestamp appear in the matching row in R5–R37.
Quick tip If you want to test-run from the editor (without editing the sheet), you can simulate the event by passing in a fake object, like this: javascriptCopiar códigofunction test_onEdit() { var fakeEvent = { range: SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("W5") }; onEdit(fakeEvent); }
But in normal use, you never need to "Run" — the sheet edits automatically trigger it.
⚡ Do you also want the timestamp to show only the date (yyyy-mm-dd) instead of the full date+time?