Add timestamp to named column in Google Spreadsheet onEdit script

后端 未结 2 768
半阙折子戏
半阙折子戏 2020-12-11 07:48

I\'m trying to figure out how to retrieve the index of a column with a specific name in a Google Spreadsheet script.

I\'m working on a custom Google Script that auto

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 08:07

    This was easier than I thought! Between the last 2 brackets:

    var dateCol = headers[0].indexOf('Updated By');
    
      if (dateCol > -1 && index > 1) { // only timestamp if 'Updated By' header exists, but not in the header row itself!
        var cell = sheet.getRange(index, dateCol + 1);
        var Who = Session.getActiveUser();
        cell.setValue(Who);
      }
    

提交回复
热议问题