0
I am trying to automate a part of the spreadsheet, where the date after change is inserted.
The function is like this:
function onEdit(event)
{ var Timezone = "GMT-3"; var timestamp_format = "dd-mm-yyyy"; // Timestamp Format. var updateColName = "DESCRIPTION"; var timeStampColName = "BALANCE"; var sheet = Event.source.getSheetByName("Relation"); //Sheet name where you will run this script.
var actRng = Event.source.getActiveRange(); var editColumn = actRng.getColumn(); var index = actRng.getRowIndex(); var headers = sheet.getRange(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); }`