Depending on the value of a specific cell (sheet "gegevensblad" cell L10), I would like to hide 1 out of 2 sheets (Either Overzichtsgrafieken 1 or Overzichtgrafieken 2).
The value in cell L10 can be either "Ja" or "Nee".
If value is "Ja" then hide sheet "Overzichtsgrafieken 1"
Else hide sheet "Overzichtsgrafieken 2" (or: if value is "Nee" then hide sheet "Overzichtsgrafieken 2")
I have come up with the following code:
If Sheets("Gegevensblad").Range("L10") = Ja Then Sheets("Overzichtsgrafieken 1").Visible = False Else Sheets("Overzichtsgrafieken 2").Visible = False
(in VBA the code from "If sheets" till "= False" is on one line)
When running the code it gives error 9: subscript is out of reach. The part after Else is coated in yellow.
What am I doing wrong?
Can anyone provide me with a code that works?
Noticed this and I think I can help. Your trying to read a sheet that is not there or your not calling it correctly. Say your reading Sheet 3 which is 2 in the sheets collection, or check the spelling.
send a sinpit of code if you cannot get it form here