Goes to A1 on all Worksheets when Opening Q

J

John

I got this code from this board which opens my worksheet up at A1 on a
certain worksheet. My problem is that it goes in to Debug if any of the
worksheets within the file are hidden. Is there a workaround?

Thanks

Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Select
Application.Goto Reference:=sh.Range("a1"), Scroll:=True
Next sh
ThisWorkbook.Sheets("BOIM").Select
Application.ScreenUpdating = True

End Sub
 
F

Frank Kabel

Hi
try
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
if sh.visible then
sh.Select
Application.Goto Reference:=sh.Range("a1"), Scroll:=True
end if
Next sh
ThisWorkbook.Sheets("BOIM").Select
Application.ScreenUpdating = True

End Sub
 
J

John

Thanks Frank


Frank Kabel said:
Hi
try
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
if sh.visible then
sh.Select
Application.Goto Reference:=sh.Range("a1"), Scroll:=True
end if
Next sh
ThisWorkbook.Sheets("BOIM").Select
Application.ScreenUpdating = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top