There is "End", but read the help on this before you use it. I cannot think
of a reason to use it in any code you want remotely reliable.
A better way is to make your ProcB a function and check its return value in
ProcA:
<Return Values>
Sub ProcA_Return()
If ProcB_Return = False Then Exit Sub
'Other code
End Sub
Function ProcB_Return() As Boolean 'Or Long
'Deal with errors created in code
On Error GoTo Handler
'Deal with some incorrect entries
If Range("A1").Value < 10 Then
ProcB_Return = False
Exit Function
End If
'Other code
'All OK
ProcB_Return = True
Exit Function
Handler:
ProcB_Return = False
End Function
</Return Values>
There are also ways of using Err.Raise allowing the unhandled error to
bubble up to the calling routine, which deals with it:
<Raise Errors>
Sub ProcA_Errors()
'Error handling in to the "top" Proc
On Error GoTo Handler
Call ProcB_Errors
'Other code
Exit Sub
Handler:
'Deal with the error I you can/want
MsgBox Err.Source & vbNewLine & Err.Description
End Sub
Sub ProcB_Errors()
'No error handling here
'Deal with some incorrect entries
If Range("A1").Value < 10 Then
Err.Raise 10010, "ProcB_Errors", "What is wrong"
End If
'Cause an error
MsgBox 1 / 0
End Sub
</Raise Errors>
NickHK
> Hi All,
>
[quoted text clipped - 14 lines]
> Ankur
> www.xlmacros.com
ankur - 24 Jan 2007 08:37 GMT
Thanks a lot
Perfect...
Regards
Ankur
> There is "End", but read the help on this before you use it. I cannot think
> of a reason to use it in any code you want remotely reliable.
[quoted text clipped - 78 lines]
> > Ankur
> >www.xlmacros.com- Hide quoted text -- Show quoted text -