Last active
May 24, 2018 13:36
-
-
Save jnschrag/12e8082a1bd37dbbff0f8cd7476df359 to your computer and use it in GitHub Desktop.
Google Sheets Automatic Timestamp Updater on Row Edit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onEdit() { | |
var s = SpreadsheetApp.getActiveSheet(); | |
if( s.getName() == "Member Admissions Tracker" ) { //checks that we're on the correct sheet | |
var r = s.getActiveCell(); // Get our active cell | |
var column = r.getColumn(); // Get the column of the active cell | |
var row = r.getRow(); // Get the row of the active cell | |
if(row != 1) { // Don't do this for the first row | |
if(column != 4) { // Don't do this for the timestamp column | |
var firstCell = s.getRange(row, 1) // Get the first cell in this row | |
if(firstCell.getValue() != '' ) { // Only update the timestamp if we have something in the first cell of the row | |
var cell = s.getRange(row, 4) // Select Timestamp cell for the active row | |
cell.setValue(new Date()); // Update the timestamp cell value with the latest date | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment