My goal is to have Google Sheets automatically add a timestamp beside the edited SKU, and it's working perfectly on the "Sales" tab.
The issue arises when trying to implement this on the "In Log" tab. I've searched for other solutions but haven't been able to figure it out. If someone could help me understand the problem, I would greatly appreciate it!
Here is the script:
function onEdit1(e) {
var s = SpreadsheetApp.getActiveSheet();
if (s.getName() == "In Log") {
var r = s.getActiveCell();
if (r.getColumn() == 1) {
var nextCell = r.offset(0, 4);
if (nextCell.getValue() === '')
nextCell.setValue(new Date());
}
}
}
function onEdit2(e) {
var s = SpreadsheetApp.getActiveSheet();
if (s.getName() == "Sales") {
var r = s.getActiveCell();
if (r.getColumn() == 1) {
var nextCell = r.offset(0, 5);
if (nextCell.getValue() === '')
nextCell.setValue(new Date());
}
}
}
I apologize for the messy code due to copying and pasting.
Here is a link to a copy of the Google Sheet: https://docs.google.com/spreadsheets/d/1nGPIKCjE6c_xJe7bDwhGIoFz5fJ-cpbTtavsUelxSW0/edit?usp=sharing