PDA

View Full Version : Solved: Toggle button to hide/unhide worksheets



JackyJ
09-24-2010, 03:49 AM
I wish to hide/unhide multiple sheets using a toggle button. What code do I need to add, to the following, to include Sheets 'Day 1' through 'Day 7' in the hide/unhide action?


Private Sub ToggleButton1_Click()

If Sheets("Day 1").Visible Then
Sheets("Day 1").Visible = False
Else
Sheets("Day 1").Visible = True
End If

End Sub

Thanking you

Bob Phillips
09-24-2010, 03:51 AM
Private Sub ToggleButton1_Click()
Dim i As Long

For i = 1 To 7

Worksheets("Day " & i).Visible = Not Worksheets("Day " & i).Visible
Next i

End Sub

JackyJ
09-24-2010, 03:19 PM
Simple and effective. Excellent.

Thanks.