What is a Macro in Excel?

Add to Favorites
Author: | Edits: don

This is the first step to learning about Macros for Excel and how to use them. 

What is a Macro?  

A macro is a small program that you make in Excel that automates tasks.

Basically, this "thing", the macro, can save you hours of time. You can create macros that do almost anything in Excel and even other Microsoft Office programs.

How can Macros Help Me?

Macros are useful when you want to automate a repetitive, tedious, or complex process.

For example, you can create a macro that searches through all of the data in an Excel Workbook, compiles the important information, and emails that information through Outlook, and you can do all of this with just the click of a button once you make the macro.

In a moment, we will create a simple macro together, but first let's talk about how they are made.

What is VBA?

Macros are made using VBA, which stands for Visual Basic for Applications.

Visual Basic is a programming language, and if you start learning it from a book, it can be terrifically annoying and confusing.

All you need to know is that VBA is the programming language that is used to create Macros. You DO NOT need to be a VBA expert to make macros; you just need to follow the tutorials here! :)

Your First Macro

Now that you know what a macro is, let's create a simple one so you can see just how easy it is.

  1. Open Excel and hit the keyboard shortcut Alt + F11 and this will take you to the VBA window for Excel. It should look something like this:
  2. Go to the Insert menu and then click Module:
    You should now see a window like this:
  3. In the window type Sub and then whatever name you want to give your macro and then an opening and closing parenthesis.
    Hit Enter to go to the next line and End Sub should automatically appear, like this:
    The space between these two lines is where the macro code, the VBA, will go.
  4. Here, I will type a very simple line of code that will output a pop-up message box that will say HI!
    Now, we have created a macro for Excel using VBA!
  5. Hit Alt + F11 to go back to Excel and then hit Alt + F8. This window should appear:
  6. You can see the name of the macro that we just created, my_macro. In this window, you will be able to see all of the macros that you can access. Select the macro and hit the Run button.
    You should see a window pop-up like this:
    Hit OK and the window will close.
    That's it!

We have successfully programmed and run a macro for Excel!


As you can see, the basics of creating a macro for Excel are pretty simple. It does get more complex than this, but that depends on what you want to do. The best thing about creating macros though, is that you don't have to be a master programmer or even learn a lot about VBA in order to make some very useful macros.

Basically, since you are just creating a little helper program for yourself in Excel, you only need to learn the code that will do what you need; you don't need to learn everything about VBA to make complex macros.

The tutorials here will focus on teaching you how to do things with your macros and not just about conceptual crap that you'll never use.

Keep reading to learn more! :)

Make sure to download the sample workbook attached to this tutorial if you want to see the macro that was created.

Downloadable Files: Excel File

Question? Ask it in our Excel Forum

Our Excel Courses

  • Skill Level: All Levels
  • |
  • 5 hours+

How to make a fully featured professional form in Excel that is unbreakable. This includes how to use the form to store, view, edit, and delete data from a data storage worksheet.

  • Skill Level: All Levels
  • |
  • 2 hours

Send Emails from Excel using VBA and Macros. This course starts from the Basics and builds up to more advanced examples with attaching workbooks, worksheets, PDF's, automatically sending emails, including a signature, error handling, increasing speed, and more.

Similar Content on TeachExcel
Get Data from the Worksheet into a Macro in Excel
Tutorial: Here, you'll learn how to get information from the Excel worksheet into a macro so you can...
What is a UserForm in Excel?
Tutorial: A UserForm is basically a pop-up window that you can use to create a custom interface for ...
Put Data into a Worksheet using a Macro in Excel
Tutorial: How to input data into cells in a worksheet from a macro. Once you have data in your macro...
Do Something Every so Many Rows with a Macro in Excel
Tutorial: How to have a macro do something on a set interval of rows; for instance, input a value ev...
Dates in Excel Explained
Tutorial: I'll explain how dates in Excel work and then point you to many useful tutorials on how t...
Install a Macro into an Excel Spreadsheet
Tutorial: This tip will show you how to copy an Excel Macro into your workbook or spreadsheet. You w...