How to Create and Use Macros in Excel



Excel is a powerful tool that allows you to organize and analyze data. However, performing repetitive tasks in Excel can be time-consuming and tedious. That’s where macros come in. Macros are a feature in Excel that allows you to automate tasks, saving you time and effort. In this blog, we will explore how to create and use macros in Excel.

Why Do You Need Macros?

Let’s start by understanding why macros are valuable. Imagine you have an Excel sheet with multiple sheets, and you need to perform the same task on each sheet. It could be something as simple as sorting the data or as complex as performing calculations. Without macros, you would have to manually perform the task on each sheet, which can be time-consuming and error-prone. Macros allow you to automate these tasks, ensuring consistency and saving you valuable time and effort.

What Are Macros?

A macro is a feature in Excel that allows you to record a series of actions and then play them back automatically. It essentially captures the steps you take to perform a task and allows you to repeat those steps with a single click. Macros can be used to automate a wide range of tasks in Excel, from formatting data to performing calculations.

Creating Macros

Now that we understand the benefits of macros, let’s dive into how to create them. The process involves two steps: enabling the macros option in Excel and recording your steps using macros.

Enabling Macros

To enable the macros option in Excel, follow these steps:

  1. Click on the Home tab in your Excel sheet.
  2. Right-click and select “Customize.”.
  3. In the window that appears, go to the “Developer” menu and select it.
  4. Click “OK”.
  5. You will now see a new menu item called “Developer.”.

Recording Your Steps

Once you have enabled the macros option, you can start recording your steps. Let’s take an example to understand how this works.

Imagine you have a set of contact details that you want to format. You want to separate the names into separate columns and highlight ages above 18. Here’s how you can create a macro to automate this task:

Step 1: Start Recording

Click on “Record Macro” and give your macro a name, such as “Format Contact Details.”. Choose a unique shortcut key to run the macro, and decide where you want to save your macro recordings. In this case, let’s save it in the same Excel workbook file. Finally, click “OK” to start recording your steps.

Step 2: Perform the Task

Now, perform the formatting steps manually. For example, you can add headings, rearrange the data into separate columns, and highlight ages above 18 using conditional formatting.

Step 3: Stop Recording

Once you have completed the steps, click the square button to stop recording the macro.

Running Macros

Now that you have created a macro, let’s see how to run it. There are several ways to run a macro in Excel.

Using the Macros Option

To run a macro using the macros option, follow these steps:

  1. Go to the developer menu.
  2. Click on “Macros.”.
  3. Select the macro you want to run.
  4. Click “Run”.

Using a Shortcut Key

You can also assign a shortcut key to your macro when you create it. To run the macro using the shortcut key, simply press the assigned key combination.

Using a Button

Another way to run a macro is by adding a button to your Excel sheet. Here’s how to do it:

  1. Go to the Developer menu and click on “Insert.”.
  2. Select “Button”.
  3. Click on your Excel sheet to insert the button.
  4. Select the macro you want to run.
  5. Click “OK”.

Editing Macros

If you make a mistake when recording a macro or want to make changes to an existing macro, you can easily edit it. Here’s how:

  1. Go to the Macros option and select the macro you want to edit.
  2. Click “Edit”.
  3. In the macro editor, make the necessary changes.
  4. Click “Save”.

Expanding Macro Selection

If you have recorded a macro for a specific number of rows but later have more rows of data, you can easily expand the selection without creating a new macro. Here’s how:

  1. Go to the Macros option and select the macro you want to edit.
  2. Click “Edit”.
  3. In the macro editor, adjust the selection to include the new rows of data.
  4. Click “Save”.


Excel macros are a powerful tool that can help you automate repetitive tasks and save valuable time and effort. By enabling macros, recording your steps, and running the macros, you can streamline your Excel workflow and increase productivity. Whether you need to format data, perform calculations, or automate any other task in Excel, macros can be a game-changer. So start exploring the world of macros in Excel and discover how they can simplify your work.

Thank you for reading this blog! If you found it helpful, be sure to check out our other articles and tutorials. And don’t forget to subscribe for more valuable content!

Take care, and happy Excel macro-ing

Leave a Comment