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 August 3, 2017)

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

Printing On Both Sides of the Paper

A VBA macro to allow duplex printing.

Discover More

Using Print Preview

The Print Preview feature can be a great way to see how something will look on paper without actually using any paper. This ...

Discover More

Complex Compound Formatting

Sometimes it can seem that the formatting needs of your document can easily outstrip the capabilities of Word. This is not ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

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

Setting Program Window Size in a Macro

The macro programming language used in Excel gives you a great many tools that allow you to modify the way that Excel appears ...

Discover More

Making Common Functions Available to Others

When you use macros to create functions, you might want to share those functions with others—particularly if they ...

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

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. Maximum image size is 8Mpixels. 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 5 + 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.