excel-vba Debug.Print


To print a listing of the Error Code descriptions to the Immediate Window, pass it to the Debug.Print function:

Private Sub ListErrCodes()
    Debug.Print "List Error Code Descriptions"
    For i = 0 To 65535
        e = Error(i)
        If e <> "Application-defined or object-defined error" Then Debug.Print i & ": " & e
    Next i
End Sub

You can show the Immediate Window by:

  • Selecting View | Immediate Window from the menu bar
  • Using the keyboard shortcut Ctrl-G