Rename A Macro

You can very easily rename a macro that you created either with the Macro Recorder or in the Visual Basic Editor. Doing so, however, does require accessing the actual macro code within the Visual Basic Editor.

When you create a macro in Excel using the Macro Recorder, Excel automatically writes the code for the macro in Visual Basic for Applications (VBA). When you create a macro using the Macro Recorder, the only way that you can make changes to the macro code, or the macro name, is by modifying the VBA code for the macro using the Visual Basic Editor.

To rename the desired macro, you need to open the Visual Basic Editor and change the name of the subroutine that

Excel uses to run the macro. From Excel you can accomplish this for nonhidden workbooks via Edit on the Macro dialog box to display the corresponding subroutine.

You can also rename a macro in the Personal Macro Workbook within the Visual Basic Editor. Because Excel opens the Personal Macro Workbook as a hidden file, the steps to rename the macro are slightly different from a regular macro. Essentially, the difference centers on how you access the macro code. Excel does not allow you to edit a macro in the Personal Macro Workbook from the Macro dialog box. To modify a macro in the Personal Macro Workbook you must access the Visual Basic Editor directly and then make modifications to the corresponding module in the Personal.xls project.

RENAME A MACRO

E§1 File Edit View Insert Format lools Data Window Help IM -|l'° -ll Dj-u »«an H V.

I File Edit View Insert Format Debug Run lools Add-Ins Window m \ - u x % a a « o ► „ . M I %r iff « *

Monthly Expenses s Fuel Electricity Child Can Misc.

VBAProject (Budget.«

à[email protected] Microsoft Excel Objec

B-Si Modules

¿jj^ VBAPrniprh plffirpFwr^J

E§1 File Edit View Insert Format lools Data Window Help IM -|l'° -ll Dj-u »«an H V.

¿jj^ VBAPrniprh plffirpFwr^J

RENAME A MACRO VIA THE MACRO DIALOG BOX_

I File Edit View Insert Format Debug Run lools Add-Ins Window m \ - u x % a a « o ► „ . M I %r iff « *

VBAProject (Budget.«

à[email protected] Microsoft Excel Objec

B-Si Modules

■ Keyboard Short

1/2001 by Jinjer Simon Ctr1+Shift+T

■ Keyboard Short

Range("H15") Application. End Sub

RENAME A MACRO VIA THE MACRO DIALOG BOX_

—D In the Macro dialog box, click the macro you want to rename.

Note: See Chapter 1 for information on opening the Macro dialog box.

L-H Click Edit.

■ The Visual Basic Editor displays the source code for the selected macro.

-S After the Sub keyword, type the new macro name.

Note: See Chapter 3 for more information about subroutines.

1/2001 by Jinjer Simon Ctr1+Shift+T

indB ars [ "Stop Recording").'

□ Close the Visual Basic Editor.

■ The name of the macro changes in the Macro dialog box.

0 0

Responses

Post a comment