Appendix C. VBA Error Codes

This Appendix contains a complete listing of the error codes for all trappable errors in Visual Basic for Applications (VBA). This information is useful for error trapping. For complete details, consult Excel’s help system.

Error Code

Message

3

Return without GoSub.

5

Invalid procedure call or argument.

6

Overflow (for example, value too large for an integer).

7

Out of memory. This error rarely refers to the amount of physical memory installed on your system. Rather, it usually refers to a fixed-size area of memory used by Excel or Windows (for example, the area used for graphics or custom formats).

9

Subscript out of range. You will also get this error message if a named item is not found in a collection of objects. For example, if your code refers to Sheets(“Sheet2”), and Sheet2 does not exist.

10

This array is fixed or temporarily locked.

11

Division by zero.

13

Type mismatch.

14

Out of string space.

16

Expression too complex.

17

Can’t perform requested operation.

18

User interrupt occurred. This error occurs if the user interrupts a macro by pressing the Cancel key.

20

Resume without error. This error probably indicates that you forgot the Exit Sub statement before your error handler code.

28

Out of stack space.

35

Sub or Function not defined.

47

Too many Dynamic Link Library (DLL) application clients.

48

Error in loading DLL.

49

Bad DLL calling convention.

51

Internal error.

52

Bad filename or number.

53

File not found.

54

Bad file mode.

55

File already open.

57

Device Input/Output (I/O) error. ...

Get Excel® 2007 Power Programming with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.