编辑另一个单元格时自动更新单元格中的日期-Google表格

问题描述:

我在该网站上查看了各种脚本等,这些脚本可以解决我的查询,但似乎没有一个起作用。

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

基本上我有一个Google表格,其中的成员可以更新F列中的图形。他们还应该更改G列中的编辑日期,但总是会忘记这一点,所以我希望实现自动化。

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.

有什么建议吗?

我以前尝试过这种方法,但没有用,但是我刚刚又尝试过,看来现在正在做:)

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);
}