ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I still go to the error-code after a On Error Goto? (https://www.excelbanter.com/excel-programming/297104-how-can-i-still-go-error-code-after-error-goto.html)

Michel[_3_]

How can I still go to the error-code after a On Error Goto?
 
If I use the 'On Error Goto' to send a report by email how can I
include the line code that caused the error?

And how can I still go to the vba-code-line to debug it?

It seems Err. is missing something like Err.Line or Err.Code.....

GJones

How can I still go to the error-code after a On Error Goto?
 
Hi Michel;

You can use OnError Resume Next and then after the
potiential error use this:

If Err.Count < 0 Then
GoTo ErrorHandler
End If


-----Original Message-----
If I use the 'On Error Goto' to send a report by email

how can I
include the line code that caused the error?

And how can I still go to the vba-code-line to debug it?

It seems Err. is missing something like Err.Line or

Err.Code.....
.


Ivan F Moala[_3_]

How can I still go to the error-code after a On Error Goto?
 
You can use the old Erl syntax, a remnent from old basic BUT not documented.
VB.NET still has this and it is documented.

Sub ErrLineExample()

On Error GoTo ErrorHandler
Dim intAge As Integer
Dim i As Integer
Dim str As String

10 intAge = "MyAge"
20 '//
30 i = 1 / 0
40 str = "Test"
50 i = str
60 '
70 '


Exit Sub
ErrorHandler:
MsgBox Err.Description & " Error occurred at line : " & Erl()
Err.Clear
Resume Next

End Sub

(Michel) wrote in message . com...
If I use the 'On Error Goto' to send a report by email how can I
include the line code that caused the error?

And how can I still go to the vba-code-line to debug it?

It seems Err. is missing something like Err.Line or Err.Code.....



All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com