I am trying to figure out how to get the index of a column with a specific name in a Google script spreadsheet.
I am working on a custom Google Script that automatically adds timestamps to a spreadsheet when editing it. The current version successfully adds a timestamp to the last column of the active cell.
I want to create a new version of this Script that adds a timestamp to a dedicated column using a specific column name. For example, I want to create a column in my spreadsheet named Last Updated, and I want Script to detect the index of that column and automatically add timestamps to it instead of the last column in the row.
This would work better for me, because then I could place the timestamp column wherever I want, and not worry that Script would cancel something important by accident.
My current Script is as follows:
function onEdit(event) { var timezone = "GMT-4"; var timestamp_format = "yyyy-MM-dd HH:mm:ss"; var sheet = event.source.getActiveSheet();
source share