Google Sheets is a highly versatile tool that allows you to organize and analyze data efficiently. One of the great features it offers is the ability to add a timestamp. This is incredibly useful when you want to track when data was added or modified.
What is a Timestamp?
A timestamp is a sequence of characters, denoting the date and/or time at a certain point in time. In Google Sheets, you can automatically generate timestamps that show the exact date and time a cell was modified.
How to Add a Timestamp in Google Sheets
To add a timestamp in Google Sheets, we’ll need to use Google Apps Script. This is a JavaScript-based language developed by Google to extend Google Workspace applications like Sheets, Docs, Forms, and more. Let’s take a look at how to do this.
Step 1: Open Google Apps Script Editor
First, open your Google Sheet where you want to add the timestamp feature. Click on Extensions > Apps Script. This will open the Apps Script Editor.
Step 2: Add the Code
Now, delete any existing code in the editor and replace it with the following code:
function onEdit(e) { var sheet = e.source.getActiveSheet(); if (sheet.getName() == 'Sheet1') { //change 'Sheet1' to the name of your sheet var cell = sheet.getActiveCell(); var col = cell.getColumn(); if(col == 1 || col == 2 || col == 3) { //change these numbers to the columns you want to track sheet.getRange(cell.getRow(), 4).setValue(new Date()); //change '4' to the column where you want the timestamp } } }
This script is set to run whenever you make an edit in the specified columns of your chosen sheet. When an edit is made, a timestamp is added in the column you’ve chosen to hold the timestamps.
Step 3: Save and Test
Once you’ve added the code, click on the save icon or press CTRL + S to save the project. You can name the project anything you like. Now, return to your Google Sheet and try editing a cell in the column(s) you specified in the script. You should see a timestamp appear in the timestamp column.
Conclusion
And that’s it! You’ve now learned how to add a timestamp in Google Sheets. Remember to adjust the script to suit your needs in terms of the sheet name and the columns you wish to track and place timestamps in. With this handy feature, you can now easily track when data in your sheet is edited.