Last active
September 25, 2017 19:44
-
-
Save willinspire/418999ab00791c52f1b9bdd5c0e40660 to your computer and use it in GitHub Desktop.
A Google Apps Script for generating automated time stamping in Google Sheets
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
/*///////////////////////////////////////////////////////////////////////// | |
SHEET TIME STAMPER - (FOR USE IN GOOGLE SHEETS) | |
The initial configuration generates a unique time stamp on the line of | |
of the specified sheet ("Sheet1") whenever the corresponding cell in | |
column 4 is NOT empty. Included is an additional configuration which will | |
perform this same action on multiple columns simultaneously. | |
############################### | |
### "think outside the box" ### | |
### ($) ¯\_(ツ)_/¯ (฿) ### | |
############################### | |
/////////////////////////////////////////////////////////////////////////*/ | |
function onEdit() { | |
var s = SpreadsheetApp.getActiveSheet(); | |
if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet | |
var r = s.getActiveCell(); | |
if( r.getColumn() == 4 ) { //checks the column | |
var nextCell = r.offset(0, 1); | |
if( nextCell.getValue() === '' ) //is empty? | |
nextCell.setValue(new Date()); | |
} | |
} | |
} | |
/*///////////////////////////////////////////////////////////////////////// | |
function onEdit() { | |
var s = SpreadsheetApp.getActiveSheet(); | |
if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet | |
var r = s.getActiveCell(); | |
if( r.getColumn() == 5 ) { //checks the column | |
var nextCell = r.offset(0, 1); | |
//if( nextCell.getValue() !== '' ) //is empty? | |
nextCell.setValue(new Date()); | |
} | |
if( r.getColumn() == 7 ) { //checks the column | |
var nextCell = r.offset(0, 1); | |
//if( nextCell.getValue() !== '' ) //is empty? | |
nextCell.setValue(new Date()); | |
} | |
if( r.getColumn() == 9 ) { //checks the column | |
var nextCell = r.offset(0, 1); | |
//if( nextCell.getValue() !== '' ) //is empty? | |
nextCell.setValue(new Date()); | |
} | |
} | |
} | |
/////////////////////////////////////////////////////////////////////////*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment