我正在尝试使用以下通用脚本,并仅将其应用于特定列。我如何指定表格中的F列?
function onEdit(e){
// Set a comment on the edited cell to indicate when it was changed.
var range = e.range;
range.setNote('Last modified: ' + new Date());
}
答案 0 :(得分:1)
function onEdit(e) {
var range = e.range;
// if you want to test a specific sheet, un-comment the following the following and move the range test inside this if
/* if (range.getSheet().getName() === 'required sheet') {
// do something
}*/
if (range.getColumn() == 6) {// 6 is for col F
range.setNote('Last modified: ' + new Date());
}
}
这应该有效。如果它是F(在这种情况下为6),则测试范围的列并设置注释。
答案 1 :(得分:0)
以Karan的伟大答案为基础。通过此操作,您可以修改行并更新已修改行中的列。
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Sheet1')
var row = e.range.getRow();
// 'A' specifies the columns
var range = sheet.getRange('A'+ row)
Logger.log(range)
range.setNote('Last modified: ' + new Date());
}