View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JWolf JWolf is offline
external usenet poster
 
Posts: 136
Default Error with code... ".Visible"

Try "Sheet9" instead of "Sheet_9"

Tim wrote:
When I run the code below I get the following error:
Run-time error '1004'
Method 'Visible' of object '_Worksheet' failed

This only displays when I have the debug set to break on all errors.

This code is supposed to hide 8 worksheets and leave number 9
visible...the error occurs with Sheet_7
For Each wSheet In ThisWorkbook.Worksheets
If wSheet.CodeName = "Sheet_9" Then
wSheet.Visible = xlSheetVisible
Else
wSheet.Visible = xlSheetVeryHidden
End If
Next wSheet
...any ideas on what's up?

Tim