如何确定在Google表格脚本编辑器中哪一行已更改/更新 [英] How to determine which row has changed/updated on Google Sheets Script Editor
问题描述
对于我的Google表格,每一行都是随机填充的,但是当它填充时,我要一个函数运行.每次填充某些内容时,它都是下一行(不是单元格或随机行).
For my google sheets, each row gets populated at random, but when it does get populated, I want a function to run. Each time something gets populated, it's the next row (it's not a cell or a random row).
我现在正在运行onChange触发器.设置为在更改时从电子表格运行FunctionA".在该函数中,如何获取已专门更改/更新的行?不管该行是什么,我将使用什么函数/方法?
I have the onChange trigger running right now. It is set to "run FunctionA from Spreadsheet on change". In that function, how do I grab the row that has been specifically changed/updated? What is the function/method I would use to manipulate whatever that row is?
我四处搜寻,但找不到合适的答案.
I searched around but couldn't find an appropriate answer.
推荐答案
您应使用onEdit
电子表格事件. ( https://developers.google.com/apps-script/guides/triggers /events )
You should use the onEdit
spreadsheet event. (https://developers.google.com/apps-script/guides/triggers/events)
您可以这样称呼:
function onEdit(e){
//Access the range with your parameter e.
var range = e.range;
var row = range.getRow();
var column = range.getColumn();
//do whatever you need with that range
}
当在电子表格的单元格上进行编辑时,它将自动运行.
It will automatically run when there is an edit on a cell of the spreadsheet.
这篇关于如何确定在Google表格脚本编辑器中哪一行已更改/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!