
This quick lesson shows you how to edit a basic macro in Excel.
For the purpose of this lesson, we go through the steps on a PC running the Windows operating system. In addition, these steps should work perfectly in Excel 2007 or higher.
Before we start, you need a macro to edit. We will use the macro from our Hello World lesson to perform basic edits in this lesson. If you have not done so, then go through the Hello World lesson to catch up. Otherwise, feel free to just follow along.
A macro is a set of commands or actions that make it easier for you to perform tasks you plan to use often.
Edit a basic macro in Excel
Before we start, we will illustrate the problem.
The problem
Here is the problem…
When we run the hello world macro, it displays “Hello, world!” However, it jumps to cell D2. That is because, the Enter key action is part of the macro.
Therefore, we want to stop jumps to any cells, after showing hello world.
The steps
Follow the steps below to edit a macro.
Steps 1 and 2

- Click Developer from the toolbar to show Developer ribbon.
- Under the Code group, click on the Macros option. This will show you a list of macros available for you to use.
Steps 3 and 4

- Under the Macro dialog box, select your macro. Of course, our’s is hello_world.
- Click the Step into button to view the code. Also, this takes you into debug mode.
Step 5

- In the hello world subroutine, highlight the VBA code Range(“D2”).Select, and press Delete.
Note: Your code may show a range pointing to a direction location.
Steps 6 and 7

- Select File from the menu. If you did not save, then click on the save.
- Click Close and Return to Microsoft Excel.
Step 8

- When you attempt to close the VBA debugger, you may receive a prompt. Make sure you save first, and click OK to return to Excel.
Now, you have to test it.
Test it out
To test out our changes, we simply re-run the macro. Therefore, follow the same steps to run the macro, in the same way you did when you ceated the macro. See Steps 3 and 4 above. But, select Run instead.
Success!
So, our update works for us. Did it work for you? If so, then congratulations!
Otherwise, give it another shot.