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

Controlling Scroll Bars

Scroll bars are helpful if you have a document that won't fit entirely within the program window. Here's how to turn off the ...

Discover More

Selectively Importing Records

Want to easily control which records get imported from a text file into Excel? It's easy to do when you write the macro that ...

Discover More

Valid Numbers in Form Fields

When you create a form you need to use special form fields. If you want to limit what users can enter in a form field, you'll ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Macro Runs Slowly, but Steps Quickly

When you have a macro that processes a huge amount of data, it can seem like it takes forever to finish up. These slowdowns ...

Discover More

Creating a Directory in a Macro

One of the things you can do with macros is to work with disk files. As you do so, you may have a need to create a new ...

Discover More

Debugging a Macro

Part of writing macros is to make sure they work as you expect. This involves a process known as debugging. Here's how you ...

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 6 - 3?

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.