VBA (Visual Basic for Applications) is the official programming language of Excel. You can do tasks programmatically (those which you find it hard to do manually)
A macro is nothing but a VBA program. Now let’s create our first macro.
Go to View menu and click on Macros. Select Record Macro, as shown below:
Once you choose the option ‘Record Macro’, you will get this screen:
Now enter the Screen Information as given below and click on ‘OK’.
Now go back to the Macros option and click on View Macros.
Choose Edit option and it will open up a VBA Screen like this:
On the left side is information about Which Excel Sheet you are working on and the module name (Module1). On the right is the place where you will write the VBA code. Note that the Sub is the name of the Subroutine (My_first_macro) and the End Sub is the closing of this Subroutine. Whatever other info starting with single quotes (‘) are all comments.
Now, enter this information on the right side.
Now go to Run option and run the code or simply press the Play button on the tool bar.
And you will now get a screen output like this :
This is the code that you wrote for your macro.
Congratulations. You have successfully written your first VBA Macro program.