Excel Guides

Renaming a Macro in Excel

When you rename a macro in Excel, the changes will be reflected in the Macro dialog box and in the Visual Basic Editor (VBE). To rename a macro, do the following:

  1. In the Macro dialog box, select the macro you want to rename.
  2. Click Rename.
  3. In the Rename Macro dialog box, type the new name for the macro.
  4. Click OK.

To rename a macro using the Visual Basic Editor:

  1. Open the Visual Basic Editor (VBE) by pressing Alt+F11 on your keyboard.
  2. In the Project Explorer pane, expand Microsoft Excel Objects and double-click on ThisWorkbook.
  3. In the code window, find the line that starts with "Sub" followed by the name of the macro you want to rename. For example:

    Sub Macro1() 
    
  1. Replace that line with a new line that starts with "Sub" followed by the new name for your macro. For example:

Sub NewMacroName() 



















  
  1. Save your workbook. The new name for your macro will now be reflected in both the Macro dialog box and in the VBE.

  2. Additional Information

      About renaming macros

        Caution

          When you rename a macro , any code that calls or runs that macro will no longer work unless you also update those references to reflect the new name . This includes code in other macros , worksheets , or workbooks . If you have a lot of code that calls or runs a particular macro , it may be easier to delete the old macro and create a new one with the desired name .

          < span class = ""msoCommentReference"" > < span class = ""MsoCommentText"" lang = ""EN_US"" > About editing macros using Visual Basic Editor < / h3 > < ul class = ""msoNormal"" lang = ""EN_US"" >< li >< p class = ""msoNormal"" lang = ""EN_US"" >< span class = ""MsoCommentReference"" > < span class = ""MsoCommentText"" lang = ""EN_US"" > The Visual Basic Editor is a tool that allows you to view and edit macros and other code used by Microsoft Office applications . It can be opened from within Excel by pressing Alt + F11 on your keyboard . Once open , you will see two panes : The Project Explorer pane on the left , which shows all of the objects in your current workbook , and the Code window on the right , which shows the code for the currently selected object . < / p > < / li >< li >< p class = ""msoNormal"" lang = ""EN_US"" >< span class = ""MsoCommentReference"" > < span class = """", MSCOMMENTTEXT,"""" lang=""en--us"">

        • "When working with macros in Excel, it is important to keep in mind that any changes you make using Visual Basic Editor will only be saved in your current workbook. If you want to make changes to a macro that is stored in another file, such as a Personal Macro Workbook (PMW), you will need to open that file in Visual Basic Editor and make your changes there."

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.