Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Renaming a Macro.

Renaming a Macro

by Allen Wyatt
(last updated January 5, 2013)

9

A macro is nothing more than a series of instructions you want the computer to execute. It is a program which is run in the context of the application you are using. As you create macros, you will probably come across a need to rename a few of the existing macros. To do this, follow these steps:

  1. Press Alt+F8 to display the Macros dialog box.
  2. From the list of macros displayed, select the one you want to rename.
  3. Click on Edit. The VBA Editor is displayed, with the code for the selected macro visible.
  4. At the top of the macro is the keyword "Sub" followed by the macro name, then a pair of parentheses.
  5. Change the macro name as desired, but leave "Sub" there, as well as the parentheses.
  6. Close the VBA Editor.

Remember that if you rename a macro, you may need to make other changes, as well. For instance, if you have the macro referenced (called) from a different macro, you'll need to change that other macro to reflect the name as you just changed it. If the macro is also referenced in toolbar buttons or in menus, you'll need to make changes in those to reflect the new name, as well.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2924) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Renaming a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Determining How Many Windows are Open

You can open multiple documents at the same time in Word, and each document occupies its own document window. Here's a way ...

Discover More

Hiding Excel in VBA

Want to have you macro completely hide the Excel interface? You can do so by using the Visible property for the Excel ...

Discover More

Using the Fill Handle from the Keyboard

The fill handle can save a huge amount of time when you are editing a worksheet. If you are really good at using the keyboard ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

MORE EXCELTIPS (MENU)

Getting Big Macros to Run

Troubleshooting an Excel macro when it causes the entire computer to freeze can be a tedious affair. This tip provides some ...

Discover More

Deriving the Worksheet Name

Excel doesn't provide an easy way to grab the worksheet name for use within a worksheet. Here are some ideas on ways you can ...

Discover More

Splitting Information into Rows

Got too much information in a single cell? Here's how you can use a macro to pull apart that information and put it into ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 3 - 0?

2017-01-26 16:02:03

Joe Maier

Module C1_test1 exists
I tried to create ne module named C1_test2
Get error msg not allowing the creation


2017-01-09 12:17:21

DID

Re: After renaming a module, shortcuts do not work... answer to this problem...

>>>It looks like you gave your module the same name as the macro. If you did then that is the problem. This will confuse the VBA compiler. I will use underscores in my module names (spaces are not allowed) so I know what the macro is but not confuse VBA.

For example, I would name the module CGM_Formatting_WIRELINE and the macro name would be CGMFormattingWIRELINE. Change the name, resave the file, and you should be okay.<<<

http://www.mrexcel.com/forum/excel-questions/568764-visual-basic-applications-module-name.html

This solved my problem(S) that have been going on for a long time and I could not find the answer!


2015-06-08 12:15:07

David

I changed the name of a macro, now I can not find it! Any help would be great!


2015-05-07 12:02:50

Larry

I rename the module from module 1 to a different name, but now the shortcut keys that was assigned to module 1 is not working, and when I view the list of macros this macro name has had the file name added to it plus the macro name has been added again. Example: FileName.MacroName.MacroName instead of just MacroName. Does anyone have any suggestions on how to fix this problem?


2015-04-15 08:13:59

Naser

I like it, it helps.
Thanks... :)


2014-08-27 05:56:09

Willy Vanhaelen

Simply reassign the shortcut.


2014-08-26 17:23:07

Shahid

I am having the similar issue
I rename the module from module 1 to a different name, but now the shortcut that was assisgnged to module 1 is not working, how to I fix it
Any suggesstions


2014-04-08 03:27:18

Andy Y

Thanks for the tip! Very helpful.


2013-08-13 03:08:11

Premchandar

Glad with your tip it is so easy
Thanks
Prem


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing