Is there a trigger in Google apps script when a certain sheet comes to view? Please give some sample code. Thanks in advance..
Trigger when viewing a certain sheet in google apps script
52 views Asked by Danny Joseph At
2
There are 2 answers
5
On
There is no trigger to determine which sheet is currently being viewed. And even if you try to use a combination of a time trigger and getActiveSheet() or getCurrentCell(), you will get Sheet1. But by using onEdit(), you can determine which sheet is currently being edited.
function onEdit() {
var activeSheet = SpreadsheetApp.getActiveSheet();
Logger.log(activeSheet.getName());
if (activeSheet.getName() === "Sheet2") {
Logger.log("Gotcha!");
}
}
Maybe you can use trigger when someone is editing and getActiveSheet method. Something like: