【发布时间】:2019-05-05 12:37:03
【问题描述】:
这是我目前正在使用的脚本。我希望它自动应用于我文档中的所有工作表。请帮忙。以下是代码。
/**
* Creates a Date Stamp if a column is edited.
*/
//CORE VARIABLES
// The column you want to check if something is entered.
var COLUMNTOCHECK = 1;
// Where you want the date time stamp offset from the input location. [row, column]
var DATETIMELOCATION = [0,1];
// Sheet you are working on
var SHEETNAME = '46'
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//checks that we're on the correct sheet.
if( sheet.getSheetName() == SHEETNAME ) {
var selectedCell = ss.getActiveCell();
//checks the column to ensure it is on the one we want to cause the date to appear.
if( selectedCell.getColumn() == COLUMNTOCHECK) {
var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);
dateTimeCell.setValue(new Date());
}
}
}
我希望脚本在每个工作表上执行,这样每当我添加新工作表时,脚本就会自动运行,并在我向第 1 列添加值时帮助我向第 2 列添加时间戳。
请帮忙。
我在这里完全是菜鸟,因此一些详细的解释将对我有很大帮助。
【问题讨论】: