0
function onEdit(event)
{
  var timezone = "GMT-7";
  var timestamp_format = "MM-dd-yyyy-hh:mm"; // Timestamp Format. 
  var updateColName = "Ext Warehouse";
  var timeStampColName = "Date/Time Change";
  var sheet = event.source.getSheetByName('EXT Changes'); //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);
  }
}

And this one:

function onEdit(event)
{
  var timezone = "GMT-7";
  var timestamp_format = "MM-dd-yyyy-hh:mm"; // Timestamp Format. 
  var updateColName = "Completed";
  var timeStampColName = "Date/Time Completed";
  var sheet = event.source.getSheetByName('EXT Changes'); //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);
  }
}
-1
function onEdit(event)
{
  var timezone = "GMT-7";
  var timestamp_format = "MM-dd-yyyy-hh:mm"; // Timestamp Format. 
  var updateColName = "Ext Warehouse";
  var updateColName = "Completed";
  var timeStampColName = "Date/Time Completed";
  var sheet = event.source.getSheetByName('EXT Changes'); //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);
  }
}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.