Computer >> Computer tutorials >  >> Software >> Office

How to create and run Macros in Microsoft Excel

In Microsoft Excel, macros are recorded in Visual Basic programming language and it can be run in several ways. You can run a macro by clicking the macros command on the Developer tab, by using a combination shortcut key, by clicking on a graphic object or by clicking a button on the quick access toolbar. In this tutorial, we will explain how to create and run macros in Excel.

What is Macro?

A Macro is an action or a  set of actions that you can use to automate tasks. Macros are created as relief from doing tasks repeatedly, it helps to automate these tasks.

How to create and run a Macro in Excel

To create and run a macro in Microsoft Excel follow the steps below.

  1. Create a macro in Excel
  2. Run a macro from the Developer tab
  3. Run macros by using a combination shortcut key
  4. Run macros by clicking a button on the quick access toolbar

1] Creating Macros in Excel

Launch Microsoft Excel.

How to create and run Macros in Microsoft Excel

Ensure you have the Developer tab on the menu bar.

Click the Developer tab and click Record Macros in the Code group.

How to create and run Macros in Microsoft Excel

A Record Macro dialog box will appear.

In the dialog box give the macro a name.

You can also give the macro a shortcut key and description if you wish.

Then click OK.

While the macro is recording, you can format your table or any other actions you want to automate.

2] Run a macro from the Developer tab

Now click Stop Recording on the Developer tab in the Code group.

If you have a copy of your table in another worksheet

How to create and run Macros in Microsoft Excel

Click Macros in the Code group.

A Macro dialog box will open.

In the dialog box, you can choose the format you want to run the macro. In this tutorial, we choose to run the macro in All open Workbooks.

Then click Run.

The table that you copied to the other worksheet will have the format of the table that you change while recording the macro.

3] Run macros by using a combination shortcut key

You can add a combination key to your macro by clicking Macros on the Developer tab.

How to create and run Macros in Microsoft Excel

A Macro dialog box will open.

Inside the dialog box click the macro that you want to assign to a combination key.

Then click Options.

How to create and run Macros in Microsoft Excel

In the Macro Options dialog box, under the Shortcut key section enter a letter in the shortcut key the entry box.

You can type a description if you want.

Then click OK.

Press the combination keys to run your macro.

4] Run macros by clicking a button on the quick access toolbar

To run a macro using the quick access toolbar first assign a macro to the quick access toolbar. To do this follow the steps below.

Click the File tab.

Click Options on the backstage view.

How to create and run Macros in Microsoft Excel

An Excel Options dialog box will open.

Select the Quick Access toolbar on the left pane.

In the Choose a command list, choose Macros.

Select the macro you want to assign a button.

Then click the Add button to move the macro to the list of buttons on the quick access toolbar.

You can add a new symbol to your macro by clicking the Modify button.

How to create and run Macros in Microsoft Excel

A Modify Button dialog box will open.

In the dialog box, you can choose a symbol for your macro and you can also change its displayed name if desired.

Then click OK.

Click OK for the Excel Options dialog box.

You will see your macro on the quick access toolbar where you can click to run your macro.

We hope this tutorial helps you understand how to create and run Macros in Excel.

Related: How to Enable or Disable Macros in Office?

How to create and run Macros in Microsoft Excel