VBA – User-defined type not defined

This might seem obvious to some, but I thought I’d add a small post regarding Enums and the User-defined type not defined error.


If you are developing a new procedure and creating an Enum to simplify input variable entry and then compile your code and get an error of

User-defined type not defined error

as shown above, be sure to review where you created/placed your Enum as it needs to be in the module’s header section above the first procedure in the module.  Otherwise, you get the above error.  If that is the case, simply move your Enum block to the module header and try again, everything should fall into place and work.

2 responses on “VBA – User-defined type not defined

  1. Kent N Gorrell

    Another cause of this same compile error message may be a corruption. In that case a de-compile, re-compile and compact may be the solution.

    1. Frank Behnke

      In my case that error required a complete export of all modules, forms and classes.
      Remove all of thoses and save your (empty) workbook. Exit the excel program.
      Load your workbook and import them all again ; it should work without any flaw.

      greetings
      Frankie