我只需要修改此代码即可将日期值放在另一张纸上,而不是偏移到另一列。
此代码记录编辑单元格并将其偏移到另一列的时间。
function onEdit() {
var sheet = SpreadsheetApp.getActiveSheet();
var capture = sheet.getActiveCell();
if (sheet.getName() == "Sheet1") //sheet name
if(capture.getColumn() == 14 ) {
var add = capture.offset(0, 22); //"0" is the line in reference the cell updated, ''0'' same line, "1" reference at column "1" is 1 column to the right.
var data = new Date();
data = Utilities.formatDate(data, "GMT+8:00","HH:mm:ss");
add.setValue(data);
}
}
日期应显示在另一张纸上。而不是在同一张纸上。
答案 0 :(得分:0)
尝试一下:
function onEdit(e) {
var sh=e.range.getSheet();
if(sh.getName()!="Sheet1")return;
if(e.range.columnStart==14) {
var ash=e.source.getSheetByName('Another Sheet');//You need to set the other sheet name
ash.getRange(e.range.rowStart,e.range.columnStart).setValue(Utilities.formatDate(new Date(),"GMT+8:00","HH:mm:ss"));//I am putting it into the same row/column on the other sheet.
}
}