Optional. Specifies that the Enum type is visible throughout the project. Enum types are Public by default.
Private
Optional. Specifies that the Enum type is visible only within the module in which it appears.
name
Required. The name of the Enum type. The name must be a valid Visual Basic identifier and is specified as the type when declaring variables or parameters of the Enum type.
membername
Required. A valid Visual Basic identifier specifying the name by which a constituent element of the Enum type will be known.
constantexpression
Optional. Value of the element (evaluates to a Long). If no constantexpression is specified, the value assigned is either zero (if it is the first membername ), or 1 greater than the value of the immediately preceding membername.
Remarks
Enumeration variables are variables declared with an Enum type. Both variables and parameters can be declared with an Enum type. The elements of the Enum type are initialized to constant values within the Enum statement. The assigned values can't be modified at run time and can include both positive and negative numbers. For example:
An Enum statement can appear only at the module level. After the Enum type is defined, it can be used to declare variables, parameters, or procedures returning its type. You can't qualify an Enum type name with a module name.
Public Enum types in a class module are not members of the class; however, they are written to the type library. Enum types defined in standard modules aren't written to type libraries. Public Enum types of the same name can't be defined in both standard modules and class modules because they share the same name space. When two Enum types in different type libraries have the same name, but different elements, a reference to a variable of the type depends on which type library has higher priority in the References.
You can't use an Enum type as the target in a With block.
Example
The following example shows the Enum statement used to define a collection of named constants. In this case, the constants are colors you might choose to design data entry forms for a database.
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Extended data types (EDTs) and base enumerations (enums) are data types that are created and managed in the development environment. Base enums represent a list of literals, while EDTs are reusable data types that have a specific definition. The Application Object Tree (AOT) in finance and operations apps contains many existing EDTs and base enums that can be extended for use in your project, or you can create new data types. This module will focus on creating new data types.