I am looking for a way to add a time stamp to the last row of a column of figures any time there is a change in the above range. I have been able to find a number of examples where you can timestamp the next or last column but none for monitoring a column range and time stamping below. I am trying to get this working across multiple column with the answer showing in the same row of each.
-
Welcome to Web Applications. Please add more details regarding your research and attempts to adapt your findings. Including a demo spreadsheet having the minimal but complete details could very helpful to minimize the back and forth.– Rubén - Volunteer Moderator - ♦Commented Feb 3, 2016 at 22:34
-
Related: webapps.stackexchange.com/questions/88502/…– Rubén - Volunteer Moderator - ♦Commented Feb 3, 2016 at 22:35
-
Related: webapps.stackexchange.com/questions/4056/…– Rubén - Volunteer Moderator - ♦Commented Feb 3, 2016 at 22:37
1 Answer
I've modified the code from my answer to fit your description. In the example below, columns 2-5 (that is, B-E) of sheet named 'Sheet1' are monitored for changes. In case of change, a timestamp is inserted in the last row of that column.
To customize: change the sheetname and column bounds on line 4 of the script. If a non-contiguous range of columns is to be watched (e.g., columns 2,4,7,8), replace the conditions column >= 2 && column <= 5
with, for example, [2, 4, 7, 8].indexOf(column) > -1
function onEdit(e) {
var sheet = e.range.getSheet();
var column = e.range.getColumn();
if (sheet.getSheetName() == 'Sheet1' && column >= 2 && column <= 5) {
var row = sheet.getMaxRows();
sheet.getRange(row, column).setValue(new Date());
}
}