Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Renaming a Macro.

Renaming a Macro

Written by Allen Wyatt (last updated March 18, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


3

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 Macro 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, you'll need to make changes in those to reflect the new name, as well.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12428) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel 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

Only Inline Figures Can be Seen and Printed

Insert a graphic into a document and you expect to be able to see it. What do you do if it isn't displayed, however? Here ...

Discover More

Creating an AutoText Reference List

Need a fast, easy way to come up with a list of all the AutoText entries that you've defined? This tip presents two ways ...

Discover More

Removing a Macro from a Shortcut Key

Associate a macro with a shortcut key, and at some time you may want to break that association. (Perhaps so the shortcut ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Removing a Macro from a Shortcut Key

When you assign a macro to a shortcut key, you make it easy to run the macro without ever removing your hands from the ...

Discover More

Creating a Floating Macro Button

Macros can make your use of Excel much more powerful. If you have a macro that is triggered by an on-screen button, you ...

Discover More

Copying Pictures with a Macro

Copying information using a macro is rather simple, although there are multiple ways you can do the copying. The most ...

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}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. 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 six minus 4?

2023-03-19 10:28:13

J. Woolley

Suppose you have Sub MyOldMacro() that you want to rename Sub MyNewMacro().
Replace the following statement
Sub MyOldMacro()
with this statement
Sub MyOldMacro(Optional Param as Byte)
then add these statements:

Sub MyNewMacro()
MyOldMacro
End Sub

Any code that references MyOldMacro will continue to run without change.
Notice a Macro is a Sub with no parameter (argument). When a parameter is added, it is no longer included in the list of Macros (Alt+F8). A Sub with or without a parameter is a procedure. A Function is also a procedure. It is unfortunate that procedures are often called macros because some procedures are not Macros.


2023-03-19 01:46:16

Alex Blakenburg

@Graham Russell - just keep in mind that if you are in a code module you can use Ctrl+H (replace) and if you tick the "Current Project" box it will allow you to apply the replace to ALL the code in that workbook.


2023-03-18 05:55:39

Graham Russell

Re-naming a macro.

I use macros that are called from several worksheets and re-naming the macro involved hours of tracking and testing.
To overcome this in other wordbooks I simply put a comment in the macro saying what it does.
To me the name is unimportant.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.