【发布时间】:2020-04-26 18:25:35
【问题描述】:
我正在尝试弄清楚如何创建日期戳,以便在单元格中进行更改时随时进行修改。我对 Google App Script 也很陌生(每个人都需要从某个地方开始)。
我找到了以下关于如何创建日期戳的代码:
function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Test" ) { //checks that we're on Sheet1 or not
var r = s.getActiveCell();
if( r.getColumn() == 8 ) { //checks that the cell being edited is in column A
var nextCell = r.offset(0, -1);
if( nextCell.getValue() === '' ) //checks if the adjacent cell is empty or not?
nextCell.setValue(new Date());
}
}
}
用于在 G 列中添加日期戳,用于在 H 列中填写的任何数据。
但如果我想将 H2 中的数据更改为任何值,则 G2 中的日期保持不变。
任何人都可以提出建议。
【问题讨论】:
-
我不明白这个
But if I wanna change the data in H2 for any value, the date in G2 stay the same.你能提供一些图片展示你想要的例子吗?
标签: javascript google-apps-script google-sheets timestamp triggers