To raise a friendly error message with option to show custom error number and description, also option to end the run of Excel macro
Better than the "End - Debug" window
If no error info passed, current internal error number and description is shown
Sub Error_Raise(Optional ErrNum = "", Optional ErrDesc = "", Optional EndRun = 1)
AppName = SettingRead("AppName")
If ErrNum = "" Then ErrNum = Err.Number
If ErrDesc = "" Then ErrDesc = Err.Description
MsgBox "Error found while trying running " & AppName & "!!!" & vbCrLf & vbCrLf & _
"Error#:" & ErrNum & vbCrLf & "Error: " & ErrDesc, vbCritical
If EndRun = 1 Then
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End
End If
End Sub
AppName = SettingRead("AppName")
If ErrNum = "" Then ErrNum = Err.Number
If ErrDesc = "" Then ErrDesc = Err.Description
MsgBox "Error found while trying running " & AppName & "!!!" & vbCrLf & vbCrLf & _
"Error#:" & ErrNum & vbCrLf & "Error: " & ErrDesc, vbCritical
If EndRun = 1 Then
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End
End If
End Sub
Optional ErrNum, Optional ErrDesc, Optional EndRun
Views 3,306
Downloads 1,371
CodeID
DB ID
ANmarAmdeen
610
Revisions
v1.0
Saturday
July
7
2018