Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The sheet "Cost&Marg_01" indeed exists in the file. What else could it
be? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Brent,
Try running this version: Private Sub Workbook_Open() Dim sh As Worksheet ThisWorkbook.Sheets("Cost&Marg_01").Visible = True For Each sh In ThisWorkbook.Worksheets If UCase(sh.Name) < UCase("Cost&Marg_01") Then sh.Visible = False Else sh.Visible = True End If Next End Sub --- Regards, Norman wrote in message oups.com... The sheet "Cost&Marg_01" indeed exists in the file. What else could it be? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run-time error 1004 while conditionally hiding rows as a result ofworksheet protection | Excel Discussion (Misc queries) | |||
1004 Error when hiding/unhiding rows | Excel Discussion (Misc queries) | |||
Run-Time error '1004' | Excel Discussion (Misc queries) | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Run-time error 1004 | Excel Programming |