rhombus4
Well-known Member
- Joined
- May 26, 2010
- Messages
- 586
- Office Version
- 365
- 2016
- Platform
- Windows
During my code if there is an error it jumps to errorhandler which will close a workbook if it was opened during the code. If it wasn't opened it can just ignore it
However I get run time error 9 subscript out of range on the set wb line in eh:
However I get run time error 9 subscript out of range on the set wb line in eh:
VBA Code:
Sub test()
On error goto eh
Code
Dim wb as workbook
Set wb = workbooks.open("c:\test.xlsx")
Some more code
Exit sub
eh:
On error resume next
Set wb = workbooks("test.xlsx")
wb.close
On error goto 0
End sub