Debug show vbObjectErrror is a Long

?vartype(vbObjectError) 3

Long (long integer) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647.
\


BUt, .... if you're not in a class module then you probably want to forget about vbObjectError

Required. Long integer that identifies the nature of the error. Visual Basic errors (both Visual Basic-defined and user-defined errors) are in the range 0–65535. The range 0–512 is reserved for system errors; the range 513–65535 is available for user-defined errors.

When setting the Number property to your own error code in a class module, you add your error code number to the vbObjectErrorconstant. For example, to generate the error number 513, assign vbObjectError + 513 to the Number property.


You could bit map if you didn't have too many errors


Option Explicit


Enum CustomErr
        UserCancel = 1
        UserPause = 2
        ProtectedWorkbook = 4
        CorruptWorkbook = 8
        ShellError = 16
End Enum




Enum ErrorSeverity
        Mild = 2 ^ 13
        Medium = 2 ^ 14
        Severe = 2 ^ 15
End Enum




Sub test()
    Dim sErr As String, sLvl As String
    On Error GoTo ErrHandle


'    Err.Raise UserCancel + Mild
'    Err.Raise UserCancel + Medium
'    Err.Raise UserCancel + Severe


    Err.Raise ShellError + Medium


    
    Exit Sub




ErrHandle:
    If (Err.Number And UserCancel) <> 0 Then
        sErr = "User Cancel"
    ElseIf (Err.Number And UserPause) <> 0 Then
        sErr = "User Pause"
    ElseIf (Err.Number And ProtectedWorkbook) <> 0 Then
        sErr = "Protected Workbook"
    ElseIf (Err.Number And CorruptWorkbook) <> 0 Then
        sErr = "Corrupt Workbook"
    ElseIf (Err.Number And ShellError) <> 0 Then
        sErr = "Shell Error"
    End If




    If (Err.Number And Mild) <> 0 Then
        sLvl = "Mild"
    ElseIf (Err.Number And Medium) <> 0 Then
        sLvl = "Medium"
    ElseIf (Err.Number And Severe) <> 0 Then
        sLvl = "Severe"
     End If


    
    MsgBox "Error was " & sErr & " with severity of " & sLvl
End Sub