Add a Dynamic Timestamp to Google Drive Spreadsheets

November 6, 2015
Posted in WordPress
November 6, 2015 brainchild

Add a Dynamic Timestamp to Google Drive Spreadsheets

S taying organized using Google Drive Spreadsheets helps many businesses – including Brainchild Media Group. The ability to add a dynamic timestamp to Google Drive Spreadsheets can help keep you and your team in better communication, in turn, more organized. This means a timestamp will be entered into a specified column any time a cell is edited.

To add a dynamic timestamp to Google Drive Spreadsheets, select “Tools” from the spreadsheet navigation pane, then select “Script Editor” (image 2) and enter the code below (image 3). Lastly, select “Run” from the Script Editor navigation pane, select “onEdit” (image 4) and follow the authorization process – this must be done for the script to take action. We’ve also added a step-by-step tutorial with photos to make things easier. If you have any questions or run into any issues, please comment below.

You can alter the date and time format by changing the code highlighted in red. You can also specify which column you want the timestamp entered into by changing the code highlighted in green.

function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
var r = s.getActiveCell();
if( r.getColumn() != 2 ) { //checks the column
var row = r.getRow();
var time = new Date();
time = Utilities.formatDate(time, "GMT-07:00", "MM/dd/yy, hh:mm:ss");
SpreadsheetApp.getActiveSheet().getRange('E' + row.toString()).setValue(time);
};
};

Comment (1)

  1. Zack

    This is great! I have a question though. What if I only want this function to apply to 2 tabs within a sheet? Right now, it’s effecting all tabs.

Leave a Reply

Your email address will not be published. Required fields are marked *