Chapter 1 – Introduction to VBA
Programming is way through which you get the computers solve problems.
Programming Language is a vocabulary and set of grammar rules to instruct a computer to perform specific task. For example C, C++, VB, Java, Python etc.
A set of computer instructions to perform a specific task. For example Excel, Word, Outlook etc.
VBA stands for Visual Basic for Applications. It is a programming language which is designed to automate rule based tasks in MS Office applications such as Excel, Word, PowerPoint, Outlook, Access, Internet Explorer and other VBA supported applications.
A VBA Macro is a set of instruction written in VBA language which perform a specific task.
Macros are mostly used to save time of a user to perform a repetitive task. For example formatting a daily report where user is opens a raw Excel report and add some formatting steps like adding a border, add header row color and so on. Macros are also a great tool to add controls in your process such as verifying the data before saving the file.
Here is a before and after screenshots of a simple Excel formatting task:
Before you start working on your first VBA macro, you must know how you can access the Visual Basic Editor (VBE) available in your Excel application.
There are couple of ways you can open VBE (Visual Basic Editor) in Excel
- Option 1: Press Alt + F11 on you Excel file
- Option 2: Right click on any sheet name and click on ‘View Code’
- Option 3: Under Developer Tab click on Visual Basic button
Step 1: Click on Macros dropdown under View ribbon
Step 2: Click on ‘Record Macro…’ option
Step 3: The dialog will automatically suggest a name for the Macro. Depending on the task you are trying to record, give a meaning full name and click on ‘OK’ button
Step 4: Once you have completed recording the steps, click on Stop button on the bottom of the Excel application or ‘Stop Recording’ option under View ribbon