Auto updating a date in a cell when another cell is edited - Google Sheets

蓝咒 提交于 2020-02-06 09:29:29

问题


I have looked at various scripts etc. on this site which should solve my query but none of them seem to work.

Basically I have a Google Sheet where members can update a figure in column F. They should also change the edit date in column G but invariably forget that, so I am looking to automate it.

I am a complete novice when it comes to writing scripts etc but, as I have said, none of those I have tried have worked.

Any suggestions?


回答1:


I tried this one earlier and it didn't work but I have just tried again and it seems to be doing the job now :)

function onEdit(event) {
  var sheetName = 'Members',
  watchCol = 6, 
  stampCol = 7,
  r = event.range;

  if (r.getSheet().getName() !== sheetName
      || r.columnStart !== watchCol
      || r.rowStart < 2)
    return;
  r.getSheet()
      .getRange(r.rowStart, stampCol)
      .setValue(event.value ? new Date() : null);
}


来源:https://stackoverflow.com/questions/49180442/auto-updating-a-date-in-a-cell-when-another-cell-is-edited-google-sheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!