Greetings, Gurus,
I have a simple code to open a workbook based on a cell value, if the workbook can be found in the location, or to open it based on an inputbox if it can't find it. Then, if the routing can't find the file based on the user input, I'm trying to give a message, "Sorry, can't find the file".
I've set the error handler, but instead of going to the error handler, i get the error. "Run-time error '1004'... can't access the file."
I already know it's because the file I'm looking for isn't there, but why is vba giving this error instead of jumping to the error handler?
Here's the code:
Sub Reconcile()
On Error GoTo errHandler
Dim Ans
Dim Rng As Range
Dim InvWB As Workbook, POWB As Workbook
Set InvWB = ActiveWorkbook
Workbooks.Open Filename:="M:\Archived PO Responses\Hold\PO# " & Range("F16").Value & "*.xls"
On Error GoTo 0
GoTo Data
errHandler:
On Error GoTo NoPO
Do
Ans = InputBox("Please Enter 8 Digit PO Number")
Loop Until Len(Ans) = 8
Workbooks.Open Filename:="M:\Archived PO Responses\Hold\PO# " & Ans & "*.xls"
On Error GoTo 0
NoPO:
MsgBox ("Sorry, I can't find a Response for PO # " & Ans & "!")
End Sub
Thanks in advance for any help you can offer.
Bookmarks