Change Tab Detection on Google Spreadsheet using onSelectionChange Event Trigger with Google Apps Script – submit.md
An example script from Kanshi TANAIKE which lets you test the new
simple event trigger in Google Sheets.
onSelectionChange(e)trigger runs automatically when a user changes the selection in a spreadsheet.
In the example shared this is used to detect the user changing Google Sheet tab.