Different types of variables can be combined to create user-defined types (such as structs in the well-known C programming language). User-defined types are useful when you need to create a single variable to record multiple related information.
You can create a user-defined type with the type statement, which must be placed in the Declarations section of the module. User-defined types can be declared as Private or public with the appropriate keywords, for example:
Private Type Mydatatype
Or
Public Type Mydatatype
For example, you can create a user-defined type that records information about a computer system:
' Declaration (a standard module).
Private Type SystemInfo
CPU as Variant
Memory as Long
Videocolors as Integer
Cost as Currency
Purchasedate as Variant
End Type
Declaring a variable of a user-defined type
For the same user-defined type, it can be declared as a local, private, or common module-level variable:
Dim Mysystem as SystemInfo, Yoursystem as SystemInfo
Reference article: click
"Step-by-step learning VBA" to create a user-defined class or a custom type