Created
June 7, 2023 09:00
-
-
Save oliv-j/61ff4d0f3329b60d7f5169f18451e366 to your computer and use it in GitHub Desktop.
Google App Script - Time Stamp for Google Sheets
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
// this will check a range, and if cell is in range, then | |
//add a time stamp to the top of the column wherein the change was made. | |
function onEdit(e) | |
{ | |
var editRange = { // B4:J6 | |
top : 9, | |
bottom : 255, | |
left : 2, | |
right : 7 | |
}; | |
// Exit if we're out of range | |
var thisRow = e.range.getRow(); | |
if (thisRow < editRange.top || thisRow > editRange.bottom) return; | |
var thisCol = e.range.getColumn(); | |
if (thisCol < editRange.left || thisCol > editRange.right) return; | |
// We're in range; timestamp the edit | |
var ss = e.range.getSheet(); | |
ss.getRange(7,thisCol) // row 7, in which ever column is edited. | |
.setValue(new Date()); // Set time of edit in row 7, relevant column | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment