Chapter 1 – Introduction to VBA

Chapter 1 – Introduction to VBA

In this chapter, we are going to understand what is VBA, why we need VBA. We will also cover different sections of VBA Editor and finally record our first VBA macro.

What is Programming

Programming is way through which you get the computers solve problems.

What is Programming Language?

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.

What is an application or software?

A set of computer instructions to perform a specific task. For example Excel, Word, Outlook etc.

About VBA Macros

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.

Why we need Macros

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:

VBA for Beginners
VBA for Beginners

Introduction to Visual Basic Editor

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.

VBA for Beginners

There are couple of ways you can open VBE (Visual Basic Editor) in Excel

  • Option 1: Press Alt + F11 on you Excel file
VBA for Beginners
  • Option 2: Right click on any sheet name and click on ‘View Code’
VBA for Beginners
  • Option 3: Under Developer Tab click on Visual Basic button
VBA for Beginners
Components of VBE (Visual Basic Editor):
VBA for Beginners

Recording a Macro

Step 1:  Click on Macros dropdown under View ribbon

VBA for Beginners

Step 2:  Click on ‘Record Macro…’ option

VBA for Beginners

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

VBA for Beginners

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

VBA for Beginners
Author:
Excelsirji.com was started with the thought of making people experience easy while working with Excel, data analytics, vba, automations etc.

Leave a Reply

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

Are you a Data Enthusiast?

Join us for a ride on your data and automate your stuffs

Business Analytics
Data Analyst
Programming for Data Science
Predictive Analytics for Business