Excel is one of the most powerful tools in Microsoft's bundles. It allows you to do wonders with numbers and spreadsheets in general. But did you know you could automate certain tasks in your workflow and become even more efficient?

Yes, that's right. Thanks to Excel macro, you can easily do it.

The best thing about it is that you don't have to be a savvy visual basic developer. All you need is a bit of time, and you'll excel at coding Excel macros. Below, you can learn what a macro is and how to build a macro in Excel.

note
Note: If you are a Mac user, you might as well follow these simple steps to enable macros in Excel for your Mac computers.
In this article
    1. Start The Developer Tab
    2. Use Record Macro
    3. Add Macro Details
    4. Do the Desired Actions
    5. Completing the Macro
    1. Get access to your macros
    2. Find the macro you want to use
    3. Ensure the desired outcome
    1. Look for potential macro candidates
    2. Feel free to experiment
    3. Be mindful of relative and absolute references
    4. Install Data Recovery Tools

What Is an Excel Macro?

Let's start with the Excel macros definition. So, what is macro? In its essence, a macro is a program or set of actions. Some people also use a word script. You can run it only once or as many times as needed. You can even enable it to run 24/7 in any document to help you speed things up.

what is a macro

When creating macros in Excel, you can specify exactly what you want it to do. You can add several actions and execute all those actions with one keystroke. Writing code is not required here. Excel can simply record the actions you make and turn them into macro.

Next time you want to do those actions, you can simply press your macro key and do them automatically.

Common Uses of Excel Macros

There are numerous Excel macro use cases. Below, you can find the most common macro automations Excel users depend on on a day-to-day basis:

  • Workbook management – many users write macros to help them manage documents with multiple worksheets. Navigating this type of document can be challenging, and macros can help with it. For instance, you can create a macro to automatically insert a table of contents;
  • Data management – sorting data in a sheet or doing formulas and calculations can take a lot of your time, especially at scale. However, creating a macro and recording all your adjustments will save precious time if you need to do it again.
  • Table pivoting – macros can help you work with large data sets and extract specific data from categories and groups. Instead of doing it manually, you can create multiple pivot tables from one big data set to streamline your data analysis;
  • Microsoft Excel document organization – macros can also help keep your sheets and workbook tidy. Macros allow you to record your preferred rows and columns formatting settings, rearranging options, and what has to be deleted. This way, you can tidy your sheets with one click of a button;

If you find all this interesting and want to learn how to build and use a macro, everything you need is just a few scrolls below.

How to Build a Macro in Excel

If you wish to add a macro to Excel, you will need to follow the next steps:

Start The Developer Tab

Navigate to the "Developer" tab.

navigating to the developer tab

If you can't see it in your Excel, go to Options > Customize Ribbon. Navigate to Customize the Ribbon, locate Main Tabs, and check the Developer check box.

enabling the developer tab in settings

Use Record Macro

Click Record Macro in the Developer tab to start creating your custom Excel macro.

recording a macro in excel

Add Macro Details

Give a name to your macro and add details to help you understand what the macro is about (e.g., describe its purpose). You can also add a shortcut key to access it quickly.

adding macro details in excel

Do the Desired Actions

Click OK and perform the actions you want your macro to be able to complete. During this time, Excel will record your actions as long as you are recording.

Completing the Macro

Once you've completed all the actions you want to turn into macro, click the Stop Recording button. Your macro is ready for future use.

completing recording macro in excel

How to Run a Macro

Now that you've learned to develop macros in Excel, let's see how to run a macro. Below are the steps you need to complete to run a macro.

Get access to your macros

You've created a macro, but Excel won't show it by default. You need to access it. You can do it via the Developer tab or the View ribbon.

The first method is to navigate to the Developer tab and click the Macros button.

The second method is to navigate to the View ribbon > Macros button > View Macros button.

Find the macro you want to use

Now, you need to find the macro you want to use. If you are the only PC user, the chances are that you will have a list with only one macro (the one you've created in the previous step). If someone else uses the computer, you will have a list of macros.

Select the macro you want to use and click the Run button. Excel will execute the macro on your currently opened spreadsheet.

Ensure the desired outcome

Once you run the macro, Excel will perform all your recorded actions. It's essential to check your spreadsheet and data. Look for the changes to be able to check whether the macro did everything as planned. If it's not working correctly, you will have to go back and remake it.

Additional Tips for Building an Excel Macro

If you find macros in Excel useful, you probably want to learn more about them. Here are some tips to help you improve as an Excel macro writer.

🔍 Look for potential macro candidates

You should never macro all the actions you do in Excel. Macros are there to help you streamline the execution of multiple actions. You should start by analyzing your workflow. Write down the actions you perform on everyday basics. Try to find those that consist of numerous actions. These are your perfect candidates for macros.

🔧 Feel free to experiment

There are no rules of thumb here. Everything goes as long as it helps you improve your workflow. Experiment with macros, turning various functions and actions into macros. As you get more experienced with it, you will be able to refine your workflow and create handy macros.

📍 Be mindful of relative and absolute references

You've noticed that there is an option for macros that allows you to select relative or absolute references. Absolute reference macro will perform actions in the exact cells. Relative reference macros will perform actions relative to the cell selected. Both are pretty useful, but you must know this crucial difference to plan use cases in advance.

🚀 Install Data Recovery Tools

If a macro is designed to make changes to the data in a worksheet, there is a risk that it could inadvertently cause data loss if it is not adequately tested and validated. You need to be prepared for these situations, especially if you are just starting with macros in Excel.

You can regain your data with professional data recovery tools like Wondershare Recoverit.

Free Download
Free Download

Here is how to recover data accidentally lost with this app:

  1. Download and install Wondershare Recoverit.

    Go to the official Wondershare Recoverit website . Download and install the software. The installation is extremely fast, and the app itself is compact.

  2. Start scanning your drive.

    Open the app. Pay attention to the home screen as it lists all the drives attached to your computer. Mouse over the drive where your Excel files are located and click scan.

    scanning the drive for deleted files
  3. Restore your Excel files.

    Wait for the scan to complete. You can monitor the progress in the bottom left corner. You can restore file by file or check the box before the Excel file category to restore all deleted files. If you are uncertain which file to restore, you can select it and click the Preview button.

    restoring deleted excel files with wondershare recoverit

Conclusion

While macro Excel programming back in the day was a complicated task, today, you can simply record your actions in Excel and save them as a macro for future use. Developing macros allows you to sort your data faster, manage workbooks and pivot tables, and organize documents.

As you can see, building a macro in Excel is straightforward. The same procedure applies to creating macros using Windows 10 or 11 operating systems. Since you will work with data and are new to macros, you might accidentally delete some important data or entire files.

Fortunately, you can recover your lost data with professional data recovery tools such as Wondershare Recoverit.

Free Download
Free Download

FAQ

  • How do I create a hotkey macro?
    You can assign a shortcut key to your Excel macro by accessing the Developer tab > Macros button. Select the macro you want to assign the hotkey to. Access the Macro Options window and enter the letter you want to use as a hotkey for your macro. Click OK to save your changes. Now, you can access your macro by pressing Ctrl + the letter you’ve assigned.
  • How can I create a macro button in Excel?
    You can add a macro button in Excel by navigating to the Developer tab > Controls group and then clicking Insert > Command Button (under ActiveX Controls). Navigate to the location in the spreadsheet where you want the button to appear and navigate to Controls group > View Code. Enter the name of your macro and close the editor to add a button for the macro.
  • Can I use custom macros I develop with online Excel?
    If you decide to write your own macro code in the VBA editor, you won't be able to run them in the online version of Excel. Your macros are only allowed with the desktop version of Excel, where you can freely create, record, and execute them.
  • Where can I learn to code Excel macros?
    Microsoft Excel has support for custom-coded macros. If you don't know how to do it, you can learn it from the official Microsoft documentation for VBA programming and participate in the discussions at the official forum.
Theo Lucia
Theo Lucia Nov 16, 24
Share article: