fry
Active Member
- Joined
- Apr 25, 2007
- Messages
- 411
I was using the following code to list certain worksheets of certain colours and all was running well until all of a sudden it stopped working and popped up with the following error...
Method 'Visible'of object '_Worksheet' failed
HELLLP anyone
Method 'Visible'of object '_Worksheet' failed
HELLLP anyone
Code:
Private Sub CommandButton1_Click()
Dim curWorksheet As Worksheet
For Each curWorksheet In ThisWorkbook.Worksheets
If curWorksheet.Tab.ColorIndex = 5 Then
curWorksheet.Visible = True
Else
curWorksheet.Visible = False
End If
Next
Sheets(1).Visible = True
Sheets(1).Select
End Sub
Private Sub CommandButton2_Click()
Dim curWorksheet As Worksheet
For Each curWorksheet In ThisWorkbook.Worksheets
If curWorksheet.Tab.ColorIndex = 10 Then
curWorksheet.Visible = True
Else
curWorksheet.Visible = False
End If
Next
Sheets(1).Visible = True
Sheets(1).Select
End Sub
Private Sub CommandButton3_Click()
Dim curWorksheet As Worksheet
For Each curWorksheet In ThisWorkbook.Worksheets
curWorksheet.Visible = True
Next
End Sub
Private Sub CommandButton4_Click()
Dim curWorksheet As Worksheet
For Each curWorksheet In ThisWorkbook.Worksheets
If curWorksheet.Tab.ColorIndex = 3 Then
curWorksheet.Visible = True
Else
curWorksheet.Visible = False
End If
Next
Sheets(1).Visible = True
Sheets(1).Select
End Sub