View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Phil Hageman[_2_] Phil Hageman[_2_] is offline
external usenet poster
 
Posts: 2
Default Hidden Worksheet Error

Thanks, Tom. It works just as needed.
-----Original Message-----
Sub Auto_Open()
Application.ScreenUpdating = False
For Each ws In Worksheets
if ws.Visible = xlSheetVisible then
ws.Select
Application.Goto ws.Range("A1"), True
End if
Next
Worksheets("Scorecard").Select
Application.ScreenUpdating = True
End Sub

Note the ws.Select is redundant if you use

application.Goto (this selects
the sheet, goes to the cell, scrolls it to the upper left

corner).

Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
In a workbook module, the following code successfully
places the cursor in cell A1 of each worksheet, makes

each
worksheet cell A1 visible on screen, and opens the
workbook on the worksheet "Scorecard". Other worksheets
are "Customer", "Financial", etc.

Sub Auto_Open()
Application.ScreenUpdating = False
For Each ws In Worksheets
ws.Select
Application.Goto ws.Range("A1"), True
Next
Worksheets("Scorecard").Select
Application.ScreenUpdating = True
End Sub

Hiding a worksheet (FormatSheetHide), in this case
hiding "Financial", causes:

Run-time error '1004':
Select method of Worksheet class failed
Yellow arrow/yellow highlight on line: ws.select

How do I deal with hiding/unhiding worksheets?

Thanks, Phil



.