Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

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

Topic Labels: Scripting extentions
263 1
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved it by using a different code. :slightly_smiling_face: