Command button unhides but not hides

W

Wanna Learn

Hello I have command button . what I want to do is; hide or unhide the
sheet.
If I select the button it should unhide the sheet, but if I select the
button again to hide the sheet
Below is my code
the first 2 rows by themselves unhide the sheet but
When I added the last 2 rows the code it does not work.
Thanks in advance

Private Sub CommandButton1_Click()

Sheets("2008 Complete").Visible = True
Sheets("2008 Complete").Select
Sheets("2008 Complete").Visible = False
Sheets("Summary-Sheet").Select
End Sub
 
J

Jim Thomlinson

You can do it with just this one line of code. This will toggle the
visibility back and forth with subsequent clicks...

Sheets("2008 Complete").Visible = Not Sheets("2008 Complete").Visible
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Macro "on off" switch 3
Hiding / Unhiding Sheets 1
Command Button Problem 6
Unhide Multiple Sheets 2
stationary command button 2
Expand and collapse rows 7
Hide Unhide Rows 2
Macro adjustment 5

Top