INTRODUCTION TO VISUAL BASIC FOR APPLICATIONS[VBA FOR EXCEL]

Table of Contents

INTRODUCTION

VBA stands for VISUAL BASIC for APPLICATIONS.


As many of you must be aware that VISUAL BASIC is a programming language developed by the MICROSOFT in back 1960s.

It was developed as a very simple language to teach the students programming, but you can see that its still there and it is because it developed with time.


It was earlier an interpreted language (Interpreting line by line which took time for the program to be executed) but then developed into a compiled language(Converted completely into binary code then executed once and it was faster).

This VISUAL BASIC is the basis for VBA which itself shows that its the VISUAL BASIC for APPLICATION.

HISTORY OF VBA

VISUAL BASIC FOR APPLICATIONS (VBA) was first introduced in 1994 in EXCEL 5. Excel was the first application with which VBA was rolled out and after that got available for many other applications too.

From the EXCEL 5 in 1994, VBA is always there even in 2021.

Similar to VBA, there are many applications that offers the same kind of language with their software suites.

For example,

LOTUS SCRIPT for LOTUS, Gambass for LINUX,  WinWrap Basic for many applications, etc.



NEED OF VBA IN EXCEL

EXCEL provides us the option of using any formula using simple arithmetic and logical operators.

We can make any formula using these operators and implement them in our reports to get the output. In addition to this, there are many functions too, which are ready to help us.

” A function is a specific statement in which we pass the arguments and it does the job, it is meant to do”

such as SUM

The SUM function takes the numbers as input, sums them up, and returns the answer.” 

There are over 480 functions in Excel 2016 and still increasing. 

Even after that, what was the need for VBA? (VISUAL BASIC FOR APPLICATIONS). 

To understand this, let us discuss a scenario.

Suppose, we need to apply some repeated task on some cell-like loops, or we are stuck in some problem where we can’t use any of the functions, or we are making some big applications where we can’t use the operators in the same statement, in such cases the need was felt for some programming language in the back end support to make the application able to do any job. In addition to this, VBA gives us the power to automate our work in Excel.

It allows us to use forms, checkboxes, text inputs, buttons, etc. for more and more comfort while using the application. None of this was possible if VBA weren’t there.

MACRO ARE THE AUTOMATED FUNCTIONS WHICH ARE PROGRAMMED IN VISUAL BASIC FOR APPLICATIONS.”

VBA – WORKING WITH APPLICATIONS

Every application today has an object model. OBJECTS and their properties are manipulated to get the desired outcome.

The object is just like a fruit. The fruit has many specifications such as color, size, taste, age, etc.

Similarly, every application has different objects and its properties.

Such as a Chart in Excel.

Now chart has so many properties which we can change directly or through VBA to get the desired output.   

VBA WORKING WITH EXCEL

Here is the way of using VBA in Excel in the simplest words.

Applications are made to ease our jobs and to automate them.

Suppose we need to make a big report. As we all know that in any report there is quite a lot of repetition. If we start doing it manually, it’ll take days but with applications, we have to just set the formulas and functions once and then ask the machine to repeat the job. The result is, that the day’s work is done within minutes if not in seconds.

We design programs using programming techniques.

There are standard steps in any programming language.

The steps in any programming language are as follows:

1. The input is taken from the user.

2. It is processed by the program as per the logic

3. The output is given to the user.

So, these are the simple steps to understand the working of VBA.

In VBA,

1. The input is taken through the Cells or input boxes.

2. The processing is done by the program written by us in VBA

3. The output is again sent to the cells or a dialog box can be shown.

So we’ll learn VBA in these three steps.

But before that first things first. Let us see how to go to VBA section to program.

PREREQUISITES FOR LEARNING VBA

There are no specific prerequisites for learning VBA but there are a few which are helpful.

1. At least learn basic Excel first. Because we are not going to need VBA all the time.

Click here for Basic tutorials including functions.

2. Programming is not tough but if you have experience,  you can learn VBA in just one day. But this is not a requisite. Even if you don’t know the programming, we’ll learn it in a way that you understand what to do and how to do it.

3. Practice is the key to any kind of learning. So practice.