Class modules are used in VBA to create your own customized classes. Here are some examples of problems for which you might use a custom class modules:
In this chapter, we will define some class to get the idea of how class modules work. Then, we will apply the principles to some more useful examples. You are already familiar with Excel's built-in objects, such as the Worksheet object, and you know that objects often belong to collections such as the Worksheets collection. You also know that objects have properties and methods, such as the Name property and the Copy method of the Worksheet object.
Using a class module, you can create your own “blueprint” for a new object, such as an Employee class. You can define properties and methods for the class, such as a Rate property that records the employee's current rate of pay, and a ChangeTitle that implicitly affects other aspects of the Employee's data. You can also create a new collection for the object, such as the Employees collection. The class module is a plan for the objects you want ...
No credit card required