How To Work With An Excel Macro

As quoted by Microsoft:

A macro is a series of commands and functions that are stored in a Microsoft Visual Basic module and can be run whenever you need to perform the task.

We strongly agree with the statement and really find Excel Macros very useful to automate tedious jobs. We have written couple of macros and you can find them here. In this post we are sharing the steps to Create, Run and Edit an Excel Macro.

Creating Macro

First step is to create a Macro. For creating a macro, click on Tools in menu bar, select Macro and then Macros in sub menu as shown in figure below.

Clicking on Macros will open the below window. Type the name of Macro and click on Create button.

Clicking on Create button will launch the Visual Basic editor as below.

Write the code in the editor and save this Macro by closing the editor.

Running Macro

Select worksheet and run the Macro by clicking on Tools->Macro->Macros. Select the required Macro and click on “Run” button.

Editing Macro

  • Go to Tools->Macro->Macros. Select the Macro “Compare” and click on “Edit” button.
  • This will launch the Visual Basic Editor.
  • Change the code as requierd.
  • Save the Macro.

We hope that you like the post. Feel free to give your suggestions and inputs in the comments section below.

    • Also, you can compare as many entries as you want. Only thing is that it will take sometime but then status bar is updated to show the progress.

      • After seeing the excel sheet that your share, we think there is one more macro that you can look at. It compares two sheets and highlight different cells. Thus, the highlighting is at one level low i.e highlighting different cell rather than different rows. What we have observed is that with your data, rows are same with some data missing in some of the cells of that row. So, you can try the below one as well. Please note that it does not copy anything to sheet 3, it only highlight the differences in sheet 2.

        Let us know what solution you finally opted for.


Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">