Take a Guess to Win Windows 10 Pro Key!
previous arrow
next arrow
Slider

How to Run the VBA Code in Excel?

Date:2020-11-13 Author:Sandra

This article will introduce various methods of how to run VBA in Excel. Different methods are applicable to different situations, and one of them can be used according to specific needs. The “run” mentioned in this article refers to running in the Excel interface, not in the VBA editor.

Generally speaking, there are three ways to run VBA:

  1. Run from the “Developer Tools” tab
  2. Run by assigning a macro to “shape”
  3. Run by assigning a macro to the “button”

In order to demonstrate the various methods of running VBA, We open a workbook containing a VBA macro.

How to Run the VBA Code in Excel?
How to Run the VBA Code in Excel?

After entering this code, a window will pop up.

1.Run from the “Developer Tools” Tab

The Excel Developer Tools tab provides a function to view and run all the macros contained in the workbook. When you need to run a macro, open the macro list, select the macro you want to run, and click “Run”.

Specific steps are as follows:

1) Find the “Macro” button.

How to Run the VBA Code in Excel?

2) Click the Macro button, a list of all macros contained in the workbook will pop up.

How to Run the VBA Code in Excel?

3) Select the desired macro and click the “Run” button on the right to run the macro.

How to Run the VBA Code in Excel?
How to Run the VBA Code in Excel?

2.Run by Assigning a Macro to “Shape”

You can assign a macro to a shape in Excel. When the mouse clicks on it, the macro will run automatically.

The specific method is as follows:

1) Insert a shape.

How to Run the VBA Code in Excel?

2) Right-click the shape and select “Specify Macro”.

How to Run the VBA Code in Excel?

3) In the pop-up macro list, select a macro and click OK to complete.

How to Run the VBA Code in Excel?
How to Run the VBA Code in Excel?

3.Run by Assigning a Macro to the “Button”

Specific steps are as follows:

1) Find the developer tool → insert command.

How to Run the VBA Code in Excel?

2) Click the insert command and select “Form Control → Button” from the list.

How to Run the VBA Code in Excel?

3) Click the button and a list of macros will appear. Select the macro you want to specify and click OK to complete the specified macro.

How to Run the VBA Code in Excel?
How to Run the VBA Code in Excel?

The above methods are suitable for running the code contained in the workbook. Hope these can be helpful to you.

Copyright Statement: Regarding all of the posts by this website, any copy or use shall get the written permission or authorization from Myofficetricks.

Leave a Reply

Your email address will not be published. Required fields are marked *