我需要一些帮助来为此代码添加功能。到目前为止,如果 C 2 被修改,它会在 D 2 上添加一个日期戳,但我希望在我清除 C 2 上的内容时清除日期戳,但我无法成功实现这一点。
任何帮助将不胜感激。
谢谢。
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Add Payroll" ) {
//checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 3 ) {
//use getRow for row and getColumn
for column
var nextCell = r.offset(0, 1);
//offset (row,column)
if( nextCell.getValue() === "" )
//is empty?
nextCell.setValue(new Date());
//will only put date, format "123/Date and time" if time needed
}
}
}