Hide and Unhide

  • Thread starter Thread starter Ranjith Kurian
  • Start date Start date
R

Ranjith Kurian

In my excel workbook i hv created two command buttons one is S and the other
is I
I need a code so that when i click on S button it should unhide few
sheets(X, Y, Z are the three sheets) and again second time when i click the
same S button it should hide the visible sheet(X,Y,Z)
Same way for button I, when i click on I button it should unhide few
sheets(E,F,G are the three sheets) and again second time when i click the
same I button it should hide the visible sheet(E,F,G)
 
Dear Ranjith

Use the IIF function

Sheets("X").Visible= IIf(Sheets("X").Visible,false,true)
Sheets("Y").Visible= IIf(Sheets("Y").Visible,false,true)
Sheets("Z").Visible= IIf(Sheets("Z").Visible,false,true)

If this post helps click Yes
 
OR

Sheets("X").Visible= not Sheets("X").Visible
Sheets("Y").Visible= not Sheets("Y").Visible
Sheets("Z").Visible= not Sheets("Z").Visible
 
Back
Top