Microsoft Office Tutorials and References
In Depth Information
You may prefer to change the name of your project to a more descriptive name. To do so, follow these steps:
1. Select the project in the Project window.
2. Make sure that the Properties window is displayed (press F4 if it's not displayed).
3. Use the Properties window to change the name from VBAProject to something else.
After making the change, the Project window displays the new name.
Adding a new VBA module
A new Excel workbook does not have any VBA modules. To add a VBA module to a project, select the pro-
ject's name in the Project window and choose Insert Module.
When you create custom worksheet functions, they must reside in a standard VBA
module and not in a code window for a Sheet object (for example, Sheet1) or the
ThisWorkbook object. If the code for your custom function does not reside in a VBA
module, it won't work. Putting VBA code in the wrong place is perhaps the most com-
mon error made by users who are learning to write custom worksheet functions.
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 23-8 shows a VBA module named Module1 that is being renamed to CustomFunctions.
Exporting a VBA module
If you create macros that you want to share with others, one way to share the macros is to export the module
that contains them. Choose File Export File, and you are prompted for a filename and location. Exported mod-
ules are text files. You (or another user) can import these files by choosing File Import File.
Search JabSto ::




Custom Search