View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Run-time error '1004' on hiding worksheets

Hi Brent,

At least one sheet must be visible. So, if no sheet named "Cost&Marg_01"
exists, the reported error will occur. Check, therefore, that this sheet
really does exist. Perhaps there is a subtle space or spelling difference.

Providing that the named sheet does exist, your code runs without error for
me and hides all other worksheets.

---
Regards,
Norman



wrote in message
oups.com...
I have this code in

Private Sub Workbook_Open()
ActiveWorkbook.Sheets("Cost&Marg_01").Activate
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Sheets
If sh.Name < "Cost&Marg_01" Then
sh.Visible = False
Else
sh.Visible = True
End If
Next
End Sub

I get an applicaton defined or object defined error when it gets to the
sh.Visible=False line.

What have I improperly defined here?

Brent