This lesson shows you how to edit a basic macro in Excel. Before you go through this tutorial, check out creating a basic macro in Excel first. As always, you can still follow along.
Steps to Edit a Basic Macro in Excel
Follow the steps below to edit a macro in Excel.
Step 1: Open a File Containing a Macro and Show Developer Ribbon
If you do not have any Excel files containing code, then check out creating a basic macro in Excel. Otherwise, open the file containing the macro.
Click the Developer tab.
Step 2: Show Macro Dialog Box
Click Macros under the Code group within the Developer ribbon.
The Macro dialog box opens.
Step 3: Select Macro Name to Edit
- Select your macro. In our case Hello_World.
- Click Edit.
The Microsoft Visual Basic for Applications (VBA) opens, such as below.
Step 4: Make Edit to the Code
Change “Hello World!” to something else, like “Have a nice day!”.
Press Ctrl-S to save.
Note: You may want to delete Range(“A2”).Select, as it basically moves the cursor to cell A2. It is up to you.
Test Edit to Macro
Return back to your sheet and follow the steps below to test your changes.
Step 1: Show Macros
Click the Macros item in the Code group under the Developer tab. This will show the Macro dialog box.
Step 3: Find Your Macro and Run It
From the macro list, select your macro. In our case, Hello_World. Click Run.
After you clicked Run, you should see “Have a nice day!” in a cell.