X

How to Run the VBA Code in Excel?

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.

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.

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

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

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.

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

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

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

Specific steps are as follows:

1) Find the developer tool → insert command.

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

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.

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

Categories: Excel Tips
Sandra: