Vitali Skripka
Vitali Skripka

Reputation: 622

How to define from google app script on which tab it was triggered?

I have a spreadsheet with few tabs in it and i want to trigger my onEdit script only if one tab was edited. How can i from script define on which tab it is triggered?

Upvotes: 0

Views: 99

Answers (1)

CalamitousCode
CalamitousCode

Reputation: 1414

You can use the event object to find the edited range, then use the range to find the sheet, then check that the sheet's name matches the one you want;

function onEdit(e) {

    var sheetName = e.range.getSheet().getName();

    if (sheetName === 'yourSheetNameHere') {
        //do something
    }

}

Upvotes: 1

Related Questions