自动时间戳当选中单元格的复选框时

huangapple go评论52阅读模式
英文:

Autotimestamp when check the checkbox of cells

问题

我有3列,当我选择“非COD”时,列j中的单元格会自动选中,然后列L会自动添加时间戳。需要帮助插入时间戳代码的应用程序脚本。

这里是代码,我尝试插入时间戳代码,但没有任何反应,或者可能是代码的执行有助于我正确运行。

英文:

I have 3 columns , column j when I select the "NON COD" the cell is automatically checked in column K , then the column L is automatically timestamp . need help with this the app script of inserting timestamp code .

自动时间戳当选中单元格的复选框时

Here the code ,I try to inserting code of timestamp , but nothings happen or maybe the execution of code that helps me to run properly .

答案1

得分: 1

以下是翻译好的代码部分:

function onEdit(e) {
  e.source.toast("Entry");
  const sh = e.range.getSheet();
  if (sh.getName() == "Sheet0" && e.range.columnStart == 10 && e.range.rowStart > 1 && e.value == "NON COD") {
    e.source.toast("Gate1");
    sh.getRange(e.range.rowStart, 11, 1, 2).setValues([["TRUE", new Date()]]);
  }
}

请注意,代码中的 HTML 实体(如 ")已经被还原为正常的引号。

英文:

Try this:

function onEdit(e) {
  e.source.toast("Entry");
  const sh = e.range.getSheet();
  if(sh.getName() == "Sheet0" && e.range.columnStart == 10 && e.range.rowStart > 1 && e.value == "NON COD") {
    e.source.toast("Gate1")
    sh.getRange(e.range.rowStart, 11, 1, 2).setValues([["TRUE",new Date()]])
  }
}

自动时间戳当选中单元格的复选框时

huangapple
  • 本文由 发表于 2023年7月17日 09:15:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76701008.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定