Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default run-time error '9': Subscript out of range - WHY??

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default run-time error '9': Subscript out of range - WHY??

Looks to me like there's no sheet named "Reports" in the active workbook.


In article ,
pastotnikr wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default run-time error '9': Subscript out of range - WHY??

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.


"JE McGimpsey" wrote:

Looks to me like there's no sheet named "Reports" in the active workbook.


In article ,
pastotnikr wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default run-time error '9': Subscript out of range - WHY??

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!

"pastotnikr" wrote:

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.


"JE McGimpsey" wrote:

Looks to me like there's no sheet named "Reports" in the active workbook.


In article ,
pastotnikr wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run-time error '9': subscript out of range [email protected] uk Excel Discussion (Misc queries) 4 December 8th 09 10:27 PM
Run time error-subscript out of range ldd Excel Programming 0 March 21st 06 05:37 PM
Run-time error 9 (Subscript out of range) Lizz45ie[_3_] Excel Programming 3 October 26th 05 11:38 PM
Run time error 9 : Subscript out of range JAtz_DA_WAY Excel Discussion (Misc queries) 6 August 29th 05 08:26 PM
Run time error '9' Subscript out of range Tina Excel Programming 1 August 25th 03 02:05 AM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"