我正在使用Google Spreadsheets
,我想要做的是每次更新同一行中的单元格时,更新timestamp
列中包含Time last Updated
的单元格。
有什么方法可以实现吗?
提前致谢,
答案 0 :(得分:1)
未经测试,但这样的事情应该有效。由于您没有提供任何详细信息,因此您必须根据需要更改一些变量。
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());
}