• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I have the VBA to unhide a sheet but...

Kempfat

New Member
Here is the issue. I have the VBA to Unhide a hidden worksheet using checkboxes. The problem is that when the checkbox is clicked the worksheet is unhidden but does not automatically open. It remains as a tab. Can someone please help me!?


This is the VBA that I am currently using:

[pre]
Code:
Sub CheckBox1_Click()

If Sheet1.DrawingObjects("Check box 1").Value > 0 Then
Worksheets("Room 101").Visible = 1
Else
Worksheets("Room 101").Visible = 0
End If

End Sub
[/pre]

Sheet one is the master sheet with 297 checkboxes. each checkbox represents a room. so naturally, every checkbox has it's own hidden sheet.
 
Kempfat


Firstly, Welcome to the Chandoo.org Forums


Being visible isn't the same as being active or selected


I also prefer to use True and False to indicate the status of variables etc rather that 1/0

[pre]
Code:
Sub CheckBox1_Click()

If Sheet1.DrawingObjects("Check box 1").Value > 0 Then
Worksheets("Room 101").Visible = True
Worksheets("Room 101").Select
Else
Worksheets("Room 101").Visible = False
End If

End Sub
[/pre]
 
Hui, YOU ARE THE EXCEL NINJA MASTER!!! Thank you so much for leading the blind! Just one more question. Is there a way to add a close button to the sheet that is unhidden using the same string of VBA?
 
Goto the developer tab

Insert, Button


You'll need to make a subroutine like:

[pre]
Code:
Sub Hide_Rm101()
Worksheets("Room 101").Visible = False
End Sub
[/pre]
then link the button to it
 
Back
Top