Error_Raise

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

Optional ErrNum, Optional ErrDesc, Optional EndRun

Views 362 Downloads 146

'SettingRead', 'and a setting with AppName having the name of the tool', 'Error', 'description', 'message', 'custom error', 'End macro'

ANmarAmdeen
324
UI VBA-Excel
Revisions

v1.0