【发布时间】:2014-11-19 01:45:12
【问题描述】:
我正在使用Google Spreadsheets,我想要做的是每次更新同一行中的单元格时更新Time last Updated 列中包含timestamp 的单元格。
有什么方法可以实现吗?
提前致谢,
【问题讨论】:
标签: google-sheets
我正在使用Google Spreadsheets,我想要做的是每次更新同一行中的单元格时更新Time last Updated 列中包含timestamp 的单元格。
有什么方法可以实现吗?
提前致谢,
【问题讨论】:
标签: google-sheets
未经测试,但这样的东西应该可以工作。由于您没有提供任何详细信息,因此您必须根据需要更改一些变量。
function onEdit(e) {
var startCol = 2,
endCol = 10,
tsCol = 11, //this is the column where the timestamp will appear
startRow = 2,
sheetName = 'Sheet1', //this is the name of the sheet you want the script to work on.
curSheet = e.source.getActiveSheet();
//exit script when edits are made another sheet, or in the first row, or before col 2 or after col 10
if (curSheet.getName() !== sheetName || e.range.columnStart < startCol || e.range.columStart > endCol || e.range.rowStart < startRow) return;
curSheet.getRange(e.range.rowStart, tsCol)
.setValue(new Date());
}
【讨论】: