如何将触发器限制为特定的工作表/标签? [英] How do I restrict a trigger to a specific sheet/tab?
本文介绍了如何将触发器限制为特定的工作表/标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在Google表格中编写了一个脚本,该脚本将在整个电子表格完全更新时更改所选单元格中的时间戳。但是,我需要仅在更新一张纸(标签)时才更新的时间戳。这是我当前的功能:
I have written a script in google sheets that will change the time stamp in the selected cell anytime the entire spreadsheet is updated at all. However, I need the timestamp to only update when one single sheet(tab) is updated. Here is my current function:
function onEdit() {
var sheetActive = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName("Board")
.getRange('A28')
.setValue(new Date());
}
我要检查更新的工作表(标签)的名称是输入
The name of the sheet(tab) that I want to check for an update in is "Input" and the specific cell in the tab is A1 if that matters.
推荐答案
这就是您要查找的内容:
This is what you are looking for :
function onEdit(e) {
var row = e.range.getRow();
var col = e.range.getColumn();
if ( e.source.getActiveSheet().getName() === "Input" && (row==1 && col==1) ){
e.source.getSheetByName('Board').getRange('A28').setValue(new Date())
}
}
这篇关于如何将触发器限制为特定的工作表/标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文