How to determine which row has changed/updated on Google Sheets Script Editor

只谈情不闲聊 提交于 2019-12-20 01:52:09

问题


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).

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.


回答1:


You should use the onEdit spreadsheet event. (https://developers.google.com/apps-script/guides/triggers/events)

You can call it this way :

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.



来源:https://stackoverflow.com/questions/48587028/how-to-determine-which-row-has-changed-updated-on-google-sheets-script-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!