我在谷歌表单中有以下脚本:
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());
}
}
}
我从这个网站复制了它:https://spreadsheetpoint.com/insert-timestamps-in-google-sheets/#Keyboard_Shortcut_to_Insert_TimeStamp但我对它做了一点修改,以符合我的目的。
现在,我的脚本允许我在C(3(列中的单元格发生更改时获得日期,但我也希望包括F(5(列和I(7(列的单元格。我该怎么做?
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();
}
}
}