How to write Excel VBA Macros – Excel Formula


Excel VBA’s role is very important in the MS Excel application. Microsoft Excel  is main application in the MS Office. Because Office related tasks like MIS activates are getting done in the MS Excel. In order to automate this Excel tasks, VBA Macros are best choice. And we can control any application from the Excel VBA programming. Hence VBA programming has significant role in the MS Excel automations.  Usually when user is preparing some report and he is taking around one hour to do that which is not a judgmental task. Since it is copy paste work, you can automate with VBA Macro programming and save that one hour time. User has to spend time only on reviewing the report. This is what the best advantage of the Excel VBA Macros.

VBA Macros programming can be written with in the excel environment.  In order to see the VBA program environment, you have two ways. One is Alt + F11 short cut key from Excel workbook. Or you can click on view menu and then see the macro option then view option as shown in the below screen shot.

VBA Macro Environment
VBA Macro environment

Then either you can create new by giving the name or you can select the existing one, if you already written. Once you are in the VBA environment, you can see the coding, if you have already written. Else you can start writing the code in the white screen. Here there is an option called record macro. This is very useful option for the beginners. Sometimes when you are not familiar with VBA programming, this option can be used to see the exact code for particular desired thing that you want to do in the front end. This  is main feature of the excel macro programming.

Record Macro option:

This option works like a tape recorder. Just click the record macro option and start doing some activity in the Excel, you can see the pre written code in the VBA module of that excel workbook. Even intermediate users can use this option as a help to know, when one particular piece of code.  You can find the record macro option in the above screen shot.

Writing VBA Code:

When you press Alt +F11 option, you will be in the VBA Macro environment of that particular Excel workbook. Then you can insert module by clicking in the Insert menu. Once you done it, you need to start subroutine.


Adding module in the VBA Environment
Adding module in the VBA Environment

Within the below codes, we have to write the macro coding part.

Sub Testing

End sub

I am going to write small VBA Macro for you to understand yourself.

Adding two numbers program

Macro Sample program

Sub Testing

Dim I, j, k as integer



K= I + j

Range(“A1”).value = k

End sub

Similar way you need to write the vba code for any other tasks in the Excel. VBA programming is ocean to automate the things which would be available in excel. Almost every application we can control with VBA programming. All you need to do is adding the DLL of other application. Even in this programming language we can not automate the judgmental cases. This is only the drawback in this programming language. If we are effective programmer, we can just save the lot of FTEs ( Full Time Employees ) work. It would be converted into money. Sometimes If you are in six sigma projects, then we are eligible to take the green belt projects.

Hope you understand about the Excel VBA Macro the way how you can write the coding part within the Excel.




  1. It is not necessary that only tasks in Excel can be recorded in a macro. Your macro process can extend to other Office applications, and any other applications that support Visual Basic Application (VBA). For example, you can record a macro where you first update a table in Excel and then open Outlook to email the table to an email address.
    By the way! The best essay writing service –


Please enter your comment!
Please enter your name here