I am working on a project in excel 2007 that will include an index worksheet with several checkboxes on it. The check boxes will hide and unhide certain worksheets. I watched a youtube video and wrote the code for one check box and it worked great but when I added another check box it seemed to work in reverse, when the box is checked the worksheet hides and when unchecked it appears. Here is the code I am using.
Private Sub CheckBox1_Click()
If Sheets(CheckBox1.Caption).Visible = xlVeryHidden Then
Sheets(CheckBox1.Caption).Visible = -1
Else
Sheets(CheckBox1.Caption).Visible = xlVeryHidden
End If
End Sub
Private Sub CheckBox2_Click()
If Sheets(CheckBox2.Caption).Visible = xlVeryHidden Then
Sheets(CheckBox2.Caption).Visible = -1
Else
Sheets(CheckBox2.Caption).Visible = xlVeryHidden
End If
End Sub
I also have this in the Immediate box
?activesheet.visible
-1
ExcelHelp.jpg
Like I stated before the first check box works just great but check box 2 seeme to do the opposite of what I need. Any idea what I need to do?
Thanks
Bookmarks