Answers for "vba error handling"

VBA
2

vba error handling message

Dim Msg
On Error GoTo errorhandling   ' Defer error handling.
' code goes here, where potential problem occours
errorhandling:
' Check for error, then show message.
If Err.Number <> 0 Then
    Msg = "Error # " & Str(Err.Number) & " was generated by " _
            & Err.Source & Chr(13) & Err.Description
    MsgBox Msg, , "Error", Err.Helpfile, Err.HelpContext
    Err.Clear
End If
Posted by: Guest on October-06-2020
0

vba on error resume

' Example of resume after an error
Private Sub TestMe()
    Dim m As New Collection
    On Error GoTo CleanFail
    Debug.Print 1 / 0
CleanExit:
    Set m = Nothing
    Debug.Print "Clean exit"
    Exit Sub
CleanFail:
    Debug.Print Err.Description
    Err.Clear
    Resume CleanExit
End Sub
Posted by: Guest on January-23-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language