I would like for my google sheet to advance cells automatically after scanning data with a barcode scanner instead of hitting enter every time.
I'm using a barcode scanner to collect student IDs as the enter an afterschool meeting. The barcode scanner pick up their ID and I copied some script that time stamps it. However, to advance to the next cell you have to hit enter each time you scan. I'd like for the sheet to automatically advance after each time an ID is scanned. The first part of the script it the time stamp. The second part is me attempting to write a time trigger.
Full disclosure, I'm not a coding person and I have very limited knowledge. Any help would be appreciated.
function onEdit(event)
{
var timezone = "GMT-5";
var timestamp_format = "MMM-dd, hh:mm"; // Timestamp Format.
var updateColName = "Scan";
var timeStampColName = "Scan Sent";
var sheet = event.source.getSheetByName('Sheet1'); //Name of the sheet where you want to run this script.
var actRng = event.source.getActiveRange();
var editColumn = actRng.getColumn();
var index = actRng.getRowIndex();
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
var dateCol = headers[0].indexOf(timeStampColName);
var updateCol = headers[0].indexOf(updateColName); updateCol = updateCol+1;
if (dateCol > -1 && index > 1 && editColumn == updateCol) { // only timestamp if 'Last Updated' header exists, but not in the header row itself!
var cell = sheet.getRange(index, dateCol + 1);
var date = Utilities.formatDate(new Date(), timezone, timestamp_format);
cell.setValue(date);
}
}
function createTimeDrivenTriggers() {
// Trigger every 6 hours.
ScriptApp.newTrigger('myFunction')
.timeBased()
.everySec(1)
.create();
}
I want the google sheet to automatically advance cells after someone scans their ID.