I'm looking for a script for google sheet that automatically inserts a timestamp for each row. and the date and time will be updated every time any of the rows gets edited. Timestamp will be put on column 1 and the rows can be the whole rows after the row 1, no specific number of rows. Please help I am very new at this. Need it badly. Thank you
Asked
Active
Viewed 72 times
1 Answers
0
You can use an onEdit trigger from Google Apps Script.
To do that, open a script bound to your spreadsheet by clicking Tools > Script editor
, copy the following code and save the project:
function onEdit(e) {
var row = e.range.getRow();
if (row > 1) { // Check edited row is not first one
var formattedDate = Utilities.formatDate(new Date(), e.source.getSpreadsheetTimeZone(), "yyyy-MM-dd'T'HH:mm:ss'Z'"); // Format you want the timestamp, edit accordingly
e.range.getSheet().getRange(row, 1).setValue(formattedDate);
}
}
Reference:

Iamblichus
- 18,540
- 2
- 11
- 27
-
1Thank you. It worked. Ill recommend this to my friends. Thank you;;))) – ashley tago May 06 '20 at 08:32
-
@ashleytago You're welcome. Also, would you please consider [accepting this answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), if you consider it helpful? This is useful because this community relies on it to share knowledge to other users. – Iamblichus May 06 '20 at 08:53