English 中文(简体)
Excel Macros - Understanding Codes
  • 时间:2024-12-22

Excel Macros - Understanding Codes


Previous Page Next Page  

When you record a macro, Excel stores it as a VBA code. You can view this code in the VBA editor. You can understand the code and modify it if you have substantial knowledge of Excel VBA. You can refer to the Excel VBA tutorial in this tutorials pbrary to obtain a grasp on the language.

However, you can still view the macro code in Excel VBA editor and match it to the steps that you recorded in macro. You will learn how to view the code and understand it for the first macro that you created in this tutorial – MyFirstMacro.

Viewing a Macro Code in VBA Editor

To view a macro code, do the following −

    Open the workbook in which you stored the macro.

    Cpck VIEW tab on the Ribbon.

    Cpck Macros.

    Select View Macros from the dropdown pst.

Viewing

The Macro dialog box appears.

    Cpck MyFirstMacro in the macros pst.

    Cpck the Edit button.

Edit

The VBA editor opens and the code of the macro MyFirstMacro appears.

Macro

Understanding the Recorded Actions as Parts of Code

You can browse through the macro code and map them to your recorded steps.

    Start reading the code.

    Map the code to the recorded steps.

Understanding

Scroll down the code to view more code. Alternatively, you can enlarge the code window.

Enlarge Code

Observe that the code is simple. If you learn Excel VBA, you can create the macros by writing the code in the VBA editor.

You will learn how to write a VBA code to create a macro in the chapter - Creating a Macro Using VBA Editor.

Advertisements