简体   繁体   中英

How can I check more than one column with columntocheck command?

I want to save the date of operation and I found that code:

/**
* Creates a Date Stamp if a column is edited.
*/

var COLUMNTOCHECK = 9 ;
var DATETIMELOCATION = [0,1];
var SHEETNAME = 'Grupy Fb'

function onEdit(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  if( sheet.getSheetName() == SHEETNAME ) { 
    var selectedCell = ss.getActiveCell();
    if( selectedCell.getColumn() == COLUMNTOCHECK) { 
      var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);
      dateTimeCell.setValue(new Date());
      }
  }
}

However I want to run it on different columns, what should I do?

我不确定我是否正确理解了您的问题,但是您是否只希望为一列设置日期,而不仅仅是在COLUMNTOCHECK中使用所需的列并对其进行迭代来设置日期。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM