Microsoft Office Tutorials and References
In Depth Information
ADDING A NEW VBA MODULE
VBAProject to something else. After you make the change, the Project window
displays the new name.
ADDING A NEW VBA MODULE
A new Excel workbook has no VBA modules. To add a VBA module to a project,
select the project’s name in the Project window and choose Insert
Module.
RENAMING A MODULE
VBA modules have default names, such as Module1, Module2, and so on. To
rename a VBA module, select it in the Project window and then change the Name
property by using the Properties window (a VBA module has only one property —
Name). If the Properties window is not visible, press F4 to display it. Figure 13-3
shows a VBA module that is being renamed ChartMacros.
Figure 13-3: Use the Properties window to change the name of a VBA module.
REMOVING A VBA MODULE
If you want to remove a VBA module from a project, select the module’s name in
the Project window and choose File
Remove xxx, (where xxx is the name of the
module). You are asked whether you want to export the module before removing it.
Exporting a module makes a backup file of the module’s contents. You can import
an exported module into any other project.
Using code windows
Each object in a project has an associated code module, displayed in a code
window. For example, the workbook itself has a code module named ThisWorkbook.
Every worksheet and chart sheet also has a corresponding code module (for
example, Sheet1 or Chart1). Each code module has its own code window.
Search JabSto ::




Custom Search