Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Created August 30, 2021 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiejohnsonkc/3e3be68534c3f9381f007cf2960bd77c to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/3e3be68534c3f9381f007cf2960bd77c to your computer and use it in GitHub Desktop.
GoogleSheets TimeStampOnEdit (js)
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