ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Goes to A1 on all Worksheets when Opening Q (https://www.excelbanter.com/excel-programming/299978-goes-a1-all-worksheets-when-opening-q.html)

John[_78_]

Goes to A1 on all Worksheets when Opening Q
 
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



Frank Kabel

Goes to A1 on all Worksheets when Opening Q
 
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

--
Regards
Frank Kabel
Frankfurt, Germany


John wrote:
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



John[_78_]

Goes to A1 on all Worksheets when Opening Q
 
Thanks Frank


"Frank Kabel" wrote in message
...
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

--
Regards
Frank Kabel
Frankfurt, Germany


John wrote:
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






All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com