run-time error '9': Subscript out of range - WHY??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use the following code to control program flow on startup. It works fine on
2 other PCs (and worked on my PC last week), but (now) I get "run-time error
'9': Subscript out of range" when it runs on my PC.

Any ideas what might be different between the two PCs that causes it to
bomb? I have tried rebooting and compared vba references between the two PCs
-can't see anything obvious. Would appreciate any suggestions.
*****

Sub Workbook_Open()
If WorkbookExists("UPE_Period.xls") Then
BuildALL
Else
Sheets("Reports").Select
End If
End Sub
******
Public Function WorkbookExists(WorkbookName As String) As Boolean
On Error Resume Next
If Application.Workbooks(WorkbookName) Is Nothing Then
WorkbookExists = False
Else
WorkbookExists = True
End If
End Function
 
Sorry - should have been more explicit in my original post -
1) there is a sheet named "Reports" in the active workbook
2) it is failing on the call to the WorkbookExists function
3) I run the same exact worksheet on two different PCs - it fails on one but
NOT the other

Thanks for the input though.
 
Just in case someone looks at this later ... I found my problem ...
Under Tools / Options - General Tab (in the VBA programming window)

Error Trapping - Break on All Errors was selected
changed to
Break on Unhandled Errors (to match the working PC)
now works the same on both!
 

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

Back
Top