Help

If active sheets name is "..." then... but how?

Topic Labels: Scripting extentions
633 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Burak_Icel
4 - Data Explorer
4 - Data Explorer

Hey everyone,

im kinda new in google sheets and google apps script. First i got a code where a sheet is hidden, if the checkbox in a specific cell is checked.

function onEdit(a) {
  var range = a.range;
  if (range.getA1Notation() == "B13") {
    var Agenda = a.source.getSheetByName("Agenda");
    if (range.isChecked()) {
      Agenda.showSheet();
    } else {
      Agenda.hideSheet();
    }
  }
}

Now i got the problem that i have multiple sheets. But this code shall only work in one of the sheets.

So i tried two different things:

if (activeSheet.getName() !== "Allgemeine Informationen") return;

and

if (activeSheet.getName() == "Allgemeine Informationen") {
...
}

Both doesn’t work properly.

I also tried to get the value of the function by writing the value of “activeSheet.getName()” in a cell but the cell kept empty.

So Long Text Short Question: How can i put an if function that makes the code only executing when the active sheet has the name “Allgemeine Informationen”?

Friendly Regards

1 Reply 1
Burak_Icel
4 - Data Explorer
4 - Data Explorer

Solved it by using a different code. :slightly_smiling_face: