Hi, Can somebody explain me what this code means ? I guess its if an error occurs go to section ErrHandler, but why is there a resume next at the end and Exit sub inbetween ?
On Error Goto ErrHandler:
N = 1 / 0 ' cause an error
'
' more code
'
Exit Sub
ErrHandler:
' error handling code
Resume Next
End Sub
I also wrote a short code to get a better understanding. If you run it in VBA excel you will get 4 numbers that pops up in order : 1,2,2,4 I understand the first 2 numbers , but why is the third number 2 and the last one 4 ? btw for this example no error occured .
On Error Goto Err:
n = 1
MsgBox n
Err:
n = 2
MsgBox n
Resume Next
MsgBox 4
Resume Next
End Sub