chakolatemilk
chakolatemilk

Reputation: 883

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

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.

Upvotes: 4

Views: 13061

Answers (1)

Liora Haydont
Liora Haydont

Reputation: 1283

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.

Upvotes: 5

Related Questions