Create a Basic Macro in Excel – Tutorial

Create a Basic Macro in Excel

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
Developer ribbon in Excel.
Developer ribbon in Excel.

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
Developer ribbon showing Record Macro under Code group.
Developer ribbon showing Record Macro under Code group.

Click Record Macro under the Code group.

This will open the Record Macro dialog box.

Step 3: Name Your Macro
Record Macro dialog box.
Record Macro dialog box.

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.

Press OK.

Your macro is now recording. Almost every action you do is being recorded.

Step 4: Enter Some Text for the Macro
Sheet with text in cell A1.
Sheet with text in cell A1.

In cell A1, type “Hello World!” and press Enter.

Step 5: Stop Recording the Macro
Developer ribbon showing Stop Recording under Code group.
Developer ribbon showing Stop Recording under Code group.

Click on the Stop Recording item under the Code group on the Developer ribbon.

Test It

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
View Macros item under the Code group.
View Macros item under the Code group.

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
Macro dialog box.
Macro dialog box.

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.

Success!

Completed macro in Excel.
Completed macro in Excel.

You just created your first macro. Although it is fairly basic, it is a start.

Save It

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.

Additional Information

Questions and Comments

Contact us at training@techronology.com with any questions or comments.


Tutorials

Techronology Home