Written by Allen Wyatt (last updated March 18, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365
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:
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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12428) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Renaming a Macro.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
Figuring out where Windows places certain items (such as the user's desktop) can be a bit frustrating. Fortunately, there ...
Discover MoreDeveloping macros can be rewarding, but it can also be challenging. Getting individual macros to run properly is hard ...
Discover MoreNeed a quick way to change the default drive and directory in a macro you are writing? Here's the commands to do it and a ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments