Vba modules in Excel
Whenever a new macro is created in excel, it is stored in a separate entity called Module.
A module can be viewed in the VBA editor window at the left pane.
A new module is created, every time, a new VBA editor window is opened.
To understand the above point, consider you are creating a new macro as explained in earlier chapter.
Now, there will be a VBA editor window with a sub created. Now close this window and create a new macro.
Now the VBA editor opens again, but this new sub will be placed in another newly created module.
But, If the same sub was created manually below the first sub, this will be placed in the same module itself.
A collection of all modules consitiute a "Project".
There are three types of modules which are as discussed below:
General or Standard Modules
These modules corresponds to macros created from the Excel View tab.
They are placed under "Modules Folder" as Shown below:
This module is related to the Entire workbook and there is always only one module of this type for any workbook.
"ThisWorkbook" is the Workbook module.
All the events corresponding to the workbook can be coded here.
This module is related to the worksheet.And there as many modules as number of worksheets, each corresponding to a single worsheet. Worksheet modules only work on the sheet they are in.
The above screenshot shows the worksheet modules.