How to edit macro in Excel

Excel is a popular spreadsheet software used for organizing, analyzing, and manipulating data with advanced calculations and data visualization capabilities. Macros in Excel are automated scripts or recorded actions that allow users to automate repetitive tasks, perform complex calculations, and enhance productivity in Excel. However, sometimes we need to edit the code to update it or to meet some new requirements.

In this tutorial, we’ll learn how to edit the macros by using various options available in Excel. So, follow the steps explained below to learn all methods.

Method 1 – Using the View menu 

This method allows us to edit macros by using the view menu bar options. The steps are given below;

Step 1 – Open the Excel file and Go to View Menu

  • Open the Excel file containing the macro you want to edit.
  • Click on the “View” tab in the Excel ribbon and select “Macros” from the “Macros” group. As shown below.
  • You can also use the shortcut key “ALT+F8” to open the same window.

Step 2 – Select the Macros to edit

  • In the “Macro” dialog box, select the macro you want to edit and click the “Edit” button.
  • The Visual Basic for Applications (VBA) editor will open, displaying the macro code.
  • Make the necessary changes to the code based on your requirements.
  • Once you have finished editing, save the changes by clicking the “Save” button or pressing Ctrl + S.
  • Close the VBA editor and return to the Excel workbook.
  • Test the edited macro by running it in Excel to ensure it functions as intended. As shown below;

Method 2 – Using the Keyboard shortcut

This method allows us to open VBA code by pressing the keyboard short key, by which we can edit the macros directly, without having the hassle of clicks and editing. The steps are given below;

Step 1 – Open the Excel file and Press the shortcut key

  • Open the Excel file containing the macro you want to edit.
  • Click on any cell.
  • Press the keyboard shortcut key ALT +F11.
  • It will open the VB code of previously saved macros.
  • Make changes as per your requirements.
  • Click on the save button or press CTRL + S.
  • Close the VBA editor and return to the Excel workbook.
  • Test the edited macro by running it in Excel to ensure it functions as intended. As shown below;

By the above two methods, we can edit macros in Microsoft Excel,