Edit a basic macro in Excel – How to

Edit a basic macro in Excel – How to

Edit a basic macro in Excel

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
Steps 1 and 2 - Edit a macro - Developer ribbon illustrating Macros option
Developer ribbon illustrating Macros option.
  1. Click Developer from the toolbar to show Developer ribbon.
  2. 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
Steps 3 and 4 - Macro dialogue box
View macros dialog box.
  1. Under the Macro dialog box, select your macro. Of course, our’s is hello_world.
  2. Click the Step into button to view the code. Also, this takes you into debug mode.
Step 5
Step 5 - Edit a macro - Highlight and remove a line of code
Visual Basic for Applications (VBA) window opens, showing the hello world macro.
  1. 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
Steps 6 and 7 - New code listing after deleting the line of code that was causing the problem
New code listing after deleting the line of code that was causing the problem.
  1. Select File from the menu. If you did not save, then click on the save.
  2. Click Close and Return to Microsoft Excel.
Step 8
Step 8 - VBA prompt to stop debugger
VBA prompt to stop debugger.
  1. 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.


So, our update works for us. Did it work for you? If so, then congratulations!

Otherwise, give it another shot.


Education home  Excel Effects home