Trappable errors can occur while an application is running. Some of these can also occur during development or compile time. You can test and respond to trappable errors using the On Error statement and the Err function.
Code |
Message |
3 |
Return without GoSub |
5 |
Invalid procedure call |
6 |
Overflow |
7 |
Out of memory |
9 |
Subscript out of range |
10 |
Duplicate definition |
11 |
Division by zero |
13 |
Type mismatch |
14 |
Out of string space |
16 |
String formula too complex |
17 |
Can't perform requested operation |
18 |
User interrupt occurred |
20 |
Resume without error |
28 |
Out of stack space |
35 |
Sub or Function not defined |
48 |
Error in loading DLL |
49 |
Bad DLL calling convention |
51 |
Internal error |
52 |
Bad file name or number |
53 |
File not found |
54 |
Bad file mode |
55 |
File already open |
57 |
Device I/O error |
58 |
File already exists |
59 |
Bad record length |
61 |
Disk full |
62 |
Input past end of file |
63 |
Bad record number |
67 |
Too many files |
68 |
Device unavailable |
70 |
Permission denied |
71 |
Disk not ready |
74 |
Can't rename with different drive |
75 |
Path/File access error |
76 |
Path not found |
91 |
Object variable not set |
92 |
For loop not initialized |
93 |
Invalid pattern string |
94 |
Invalid use of Null |
95 |
User-defined error |
323 |
Can't load module; invalid format |
423 |
Property or method not found |
424 |
Object required |
430 |
Class does not support OLE Automation |
438 |
Object doesn't support this property or method |
440 |
OLE Automation error |
445 |
Object doesn't support this action |
446 |
Object doesn't support named arguments |
447 |
Object doesn't support current locale setting |
448 |
Named argument not found |
449 |
Argument not optional |
450 |
Wrong number of arguments |
451 |
Object not a collection |
452 |
Invalid ordinal |
453 |
Specified DLL function not found |
454 |
Code resource not found |
455 |
Code resource lock error |
You can also work with Microsoft Excel cell error values in Visual Basic. For more information, see Cell Error Values.
Code |
Message |
1000 |
'[Object]' does not have '[property name]' property The property doesn't exist for this object. For more information, see the entry for the object name. |
1001 |
'[Object]' does not have '[method name]' method The method doesn't exist for this object. For more information, see the entry for the object name. |
1002 |
Missing required argument '[argument]' The method expected a required argument that wasn't specified. Add the argument to the code. To see a list of required arguments, see the entry for the method name. |
1003 |
Invalid number of arguments The method has the wrong number of arguments. This usually occurs when you specify arguments by position instead of by name and you have too many arguments. To see the valid arguments for the method, see the entry for the method name. |
1004 |
'[Method name]' method of '[object]' class failed The method cannot be used on the object. Possible reasons include the following: An argument contains a value that isn't valid. A common cause of this problem is an attempt to access an object that doesn't exist (for example, you tried to use Workbooks(5) when there were only three workbooks open). The method cannot be used in the applied context. For example, some Range object methods require that the range contain data; if the range doesn't contain data, the method fails. An external error occurred, such as a failure to read or write from a file. For more information about the method, see the entry for the method name. |
1005 |
Unable to set the '[property name]' property of the '[object]' class The property cannot be changed. Possible reasons include the following: The value you're using for the property isn't valid (for example, you set a property to a string value, but the property requires a Boolean value). The property is read-only. For more information about the property, see the entry for the property name. |
1006 |
Unable to get the '[property name]' property of the '[object]' class The property cannot be read. A possible reason is that the property cannot be used in the applied context. For example, the code ActiveChart.Legend.Font.Color = RGB(255, 0, 0) will cause this error if the active chart doesn't contain a legend. For more information about the property, see the entry for the property name. |