OnError - what generated the error?
You can use line numbers (as in old-style Basic) and the
Erl (Error Line) variable for this:
Sub Errorhandling()
On Error GoTo ErrorHandler
10 Dim x As Integer
20 x = 0
30 x = 1 / x
Exit Sub
ErrorHandler:
MsgBox "Error occurred on line " & Erl
End Sub
There are some add-ins available to add line numbers
automatically - Google should find them.
On 10 Aug, 08:39, "Robeyx via OfficeKB.com" <u43777@uwe wrote:
A simple problem. *If an OnError routine is invoked, how can you tell which
instruction caused the error?
There must be an easy way, but I can't find it. *Single-stepping is not what
I mean, I just want there to be a field somewhere that tells me the previous
instruction executed.
--
Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200808/1
|