Microsoft Office Tutorials and References
In Depth Information
Deleting a Macro
deleting a Macro
There will be many times when you have recorded or composed a macro that you don’t need any
more. Instead of having a useless macro hanging around doing no good, it’s better to delete it. To
delete a macro, you can select its entire code in the Code window (be sure you only select from and
including the Sub line, to and including the End Sub line) and press the Delete key.
By the way, you can delete a macro from outside the VBE. While on any worksheet, if you press
Alt+F8 to call the Macro dialog box, you can select the macro name in the list and click the Delete
inserting a Module
With larger VBA projects, you’ll want to distribute your macros among two or more modules. With
large projects, you’ll be organizing your macros by some kind of theme or purpose. For example,
the macros in your company’s budget workbook that deal with reports might be placed in their
own module. Sometimes you will have no choice in the matter, because modules do have a limit as
to how much code they can individually support. To insert a new module, from the VBE menu bar,
click Insert ➪ Module as shown in Figure 4-5.
You’ll see that your new module appears in the Project Explorer window. The entry cursor will be
blinking in the new Code window, all primed and ready for you to enter VBA code into your new
module, as depicted in Figure 4-6.