Hi all,
I have an odd macro that makes use of OnError Resume Next ... my understanding is that this statement returns control of the sub to the following lines. In addition to this weird code block (I am working on a different approach, generally, but please bare with me), I want to insert a general error handler to exit the sub if a user runs into an error.
Is there a problem with having a general Error Handling label and statement, plus the second On Error Resume Next?
My feeling is that one will override the other and cause more problems ... but I'm not sure. Also, is the structure of the label statement OK?
Thanks!
I have an odd macro that makes use of OnError Resume Next ... my understanding is that this statement returns control of the sub to the following lines. In addition to this weird code block (I am working on a different approach, generally, but please bare with me), I want to insert a general error handler to exit the sub if a user runs into an error.
Is there a problem with having a general Error Handling label and statement, plus the second On Error Resume Next?
My feeling is that one will override the other and cause more problems ... but I'm not sure. Also, is the structure of the label statement OK?
Thanks!
Code:
Sub Register()
On Error GoTo ErrHandl
Dim Success As Boolean
Dim excelfile As Variant
Dim ucrWB As Workbook
Dim ucrSh1 As Worksheet
Dim ucrPath As String
'do code
Do While excelfile <> ""
Success = ""
On Error Resume Next
Set ucrWB = Workbooks.Open(ucrPath & excelfile)
Set ucrSh1 = ucrWB.Sheets(1)
Success = (Err.Number = 0)
If Success = True Then
'Do More Stuff
Else:
'Do other stuff
End If
excelfile = Dir
Loop
'Finish Code
Exit Sub
ErrHandl:
MsgBox "There was an error."
End Sub