Created
August 30, 2021 16:13
-
-
Save jamiejohnsonkc/3e3be68534c3f9381f007cf2960bd77c to your computer and use it in GitHub Desktop.
GoogleSheets TimeStampOnEdit (js)
This file contains hidden or 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() == "Sheet1" ) { //checks that we're on Sheet1 or not | |
var r = s.getActiveCell(); | |
if( r.getColumn() == 1 ) { //checks that the cell being edited is in column A | |
var nextCell = r.offset(0, 1); | |
if( nextCell.getValue() === '' ) //checks if the adjacent cell is empty or not? | |
nextCell.setValue(new Date()).setNumberFormat("yyyy-MM-dd" ); | |
var nextNextCell = r.offset(0, 2); | |
if( nextNextCell.getValue() === '' ) //checks if the adjacent cell is empty or not? | |
nextNextCell.setValue(new Date()).setNumberFormat("hh:mm AM/PM" ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment