We have a barcode scanner that we use to track student assignments. I am trying to create a Google Spreadsheet that tracks the assignments for each subject.
I have been using the following script:
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() == 13 ) { //checks the column
var nextCell = r.offset(0, 1);
if( nextCell.getValue() === '' ) //is empty?
var time = new Date();
time = Utilities.formatDate(time, "GMT", "HH:mm:ss");
nextCell.setValue(time);
}
}
}
}
However I do not know how to modify the script so that it works in multiple columns on the same spreadsheet. For example a subject may have 2 assignments: Assignment 1 and assignment 2
For assignment 1 I need to scan into column A
and have the date stamp added to column B
.
For assignment 2 I would scan into column D
on the same spreadsheet and have the date stamp added to column E
.