I run this code two different ways. First way is by clicking on the workbook icon itself and when the workbook opens the code excutes perfectly. I also have a another workbook with a form button that when pressed opens this workbook and this code runs. When the workbook opens the code errors in the module at this line: Sheets("COS Attach").Select. Any Suggestions on how to fix? Thank
This code is in ThisWorkbook:
This code is in the module:
This code is in ThisWorkbook:
Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
'Module102
Application.Run "Module102.WorkBookOpen"
Application.ScreenUpdating = True
End Sub
This code is in the module:
Code:
Private Sub WorkbookOpen()
Dim j As Integer
Dim i As Integer
Dim SmallScroll As Long
Dim ToLeft As Long
' Application.Wait (Now + TimeValue("0:00:05"))
Sheets("COS Attach").Select
Range("A7").Select
Application.GoTo reference:=ActiveCell, Scroll:=True
With ActiveWindow
i = .VisibleRange.Rows.Count / 2
j = .VisibleRange.Columns.Count / 2
.SmallScroll Up:=i, ToLeft:=j
End With
ActiveWindow.SmallScroll Down:=-20
End Sub