Macro to Perform Calculations

Here’s another example about writing a macro in VBA editor to calculate the total of salary and perks.  To write a macro in Microsoft Excel you need a knowledge of the programming language Visual Basic for Applications(VBA). VBA is easy to learn and gives you a powerful tool to automate your work in Microsoft Excel. Also you can create new applications in Microsoft Excel if you can write macros. Practice will make you perfect.

  • Click on Tools in the menu bar.
  • Select Macro.
  • Select Visual Basic Editor.
  • In the Visual Basic editor window, select ‘Insert’ from menu bar.
  • Select Module.
  • Start writing your code as demonstrated.
  • First we write the name of the macro myMacro()
  • Next we access cell address C2 and assign it the  value of B2 (salary).
  • We access D2 and assign it the value of sum of C2 and B2.
  • In this manner the total salary package is calculated.
  • The idea is to practice and learn how to create macros using the VBA editor.

Further reading:
Writing a formula using a macro

One thought on “Macro to Perform Calculations

  1. Many thanks Dinesh Bhai. You make VBA so easy for Dummies like me. I am 69 years old with zero VBA experience.

    All the best !

    Muhammed Vanker

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.