Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 我如何使我的脚本针对Google sheets中的多个列?_Google Apps Script_Google Sheets_Google Apps Script Editor - Fatal编程技术网

Google apps script 我如何使我的脚本针对Google sheets中的多个列?

Google apps script 我如何使我的脚本针对Google sheets中的多个列?,google-apps-script,google-sheets,google-apps-script-editor,Google Apps Script,Google Sheets,Google Apps Script Editor,我在Google sheet中有以下脚本: function onEdit() { var s = SpreadsheetApp.getActiveSheet(); if( s.getName() == "Sheet1" ) { //checks that we're on Sheet1 or not var r = s.getActiveCell(); if( r.getColumn() == 3) { //checks that the cell being edit

我在Google sheet中有以下脚本:

function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  if( s.getName() == "Sheet1" ) { //checks that we're on Sheet1 or not
    var r = s.getActiveCell();
    if( r.getColumn() == 3) { //checks that the cell being edited is in column A
      var nextCell = r.offset(0, 1);
      nextCell.setValue(new Date());
    }
  }
}
我从这个网站复制了它: 但我对它做了一点修改以符合我的目的

现在,我的脚本允许我在C(3)列中的单元格发生更改时获取日期,但我还希望包括F(5)和I(7)列中的单元格。如何做到这一点?

对JavaScript中的。
function onEdit(e) {
  const sh=e.range.getSheet()
  if(sh.getName()=="Sheet1") { 
    if(e.range.columnStart==3 || e.range.columnStart==6 || e.range.columnStart==9) {
      e.range.offset(0,1).setValue(new Date();
    }
  }
}