This lesson shows you how to create a basic macro in Excel. A macro is simply a set of steps to complete a task.
Steps to Create a Basic Macro in Excel
Follow the steps below to create a basic macro in Excel.
Step 1: Display Developer Tab
Click on Developer, from the menu bar to show the developer tab.
Note: If you do not see the developer tab, you may need to show it. To show the tab, go to the Show Developer Ribbon in Excel quick tip.
Step 2: Start the Macro Recorder
Click Record Macro under the Code group.
This will open the Record Macro dialog box.
Step 3: Name Your Macro
In the Macro Name box, enter Hello_World” with no spaces.
Spaces are no allowed for the macro name. Therefore, we use an underscore to separate words.
Your macro is now recording. Almost every action you do is being recorded.
Step 4: Enter Some Text for the Macro
In cell A1, type “Hello World!” and press Enter.
Step 5: Stop Recording the Macro
Click on the Stop Recording item under the Code group on the Developer ribbon.
We really need to test the macro to make sure it was a success.
To test the Hello_World macro, follow these steps:
Step 1: Delete the Contents from Cell A1
Click in cell A1 and press the Delete key. This should delete all the contents in the cell.
Step 2: 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 “Hello World!” in cell A1, or in any cell you choose.
You just created your first macro. Although it is fairly basic, it is a start.
It may be wise to save this file because we may revisit it in a different tutorial. You will probably have to save it as an Excel Macro-Enabled Workbook.