Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I based the following code on Bob Philips' code from June 30,2006 but I get a
"Subscript out of range" error at "Set lwOpenWorkbook = Workbooks(lcFile)" only when the lcFile is not open. Which is what the On Error statement should cover, right? What might be wrong and cause a runtime error despite having the On Error statement in place??? Public Sub test() Dim lwOpenWorkbook As Workbook lcFolder = "G:\Tables" lcFile = "Projects.xls" lcCurrWorkbook = ThisWorkbook.Name On Error Resume Next Set lwOpenWorkbook = Workbooks(lcFile) On Error GoTo 0 If Not lwOpenWorkbook Is Nothing Then MsgBox "Workbook is already open" Else Set lwOpenWorkbook = Workbooks.Open(lcFolder & "\" & lcFile) End If Workbooks(lcCurrWorkbook).Activate End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error 9 subscript out of range | Excel Worksheet Functions | |||
Runtime Error 9, Subscript Out of Range. When linking between word | Excel Discussion (Misc queries) | |||
Getting Excel Runtime Error 9: Subscript out of range | Excel Programming | |||
Subscript out of range error - save copy error | Excel Programming | |||
"Subscript out of range Runtime Error 9" | Excel Programming |