0% found this document useful (0 votes)
42 views2 pages

EXCEL4

The document provides an introduction to Visual Basic for Applications (VBA) and what it is capable of doing. It explains that VBA is a programming language used to automate tasks in Microsoft Office applications like Excel. It can be used to record macros to perform repetitive tasks, loop through data, and trigger events automatically. The document gives examples of how VBA can automate recurring reports, sort worksheets, and highlight the active cell.

Uploaded by

Harik C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

EXCEL4

The document provides an introduction to Visual Basic for Applications (VBA) and what it is capable of doing. It explains that VBA is a programming language used to automate tasks in Microsoft Office applications like Excel. It can be used to record macros to perform repetitive tasks, loop through data, and trigger events automatically. The document gives examples of how VBA can automate recurring reports, sort worksheets, and highlight the active cell.

Uploaded by

Harik C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Introducing VBA

Welcome to your fi rst lesson in Excel VBA 24-Hour Trainer! A good place to start is at
the beginning, where you’ll fi nd it useful to get an understanding of where Visual Basic for
Applications (VBA) comes from and what VBA is today. After you get a feel for how VBA fi ts
into the overall Excel universe, you fi nd out how to use VBA to manipulate Excel in ways you
might never have thought possible.
WHAT IS VBA?
VBA is a programming language created by Microsoft to automate operations in applications
that support it, such as Excel. VBA is an enormously powerful tool that enables you to control
Excel in countless ways that you cannot do—or would not want to do—manually.
In fact, VBA is also the language that manipulates Microsoft Offi ce applications in Access, Word,
PowerPoint, and Outlook. For the purposes here, VBA is the tool you use to develop macros and
manipulate objects to control Excel and to control other Offi ce applications from Excel.
You do not need to purchase anything more than the Offi ce suite (or the individual application)
to also own VBA. If you have Excel on your computer, you have VBA on your computer.
WHAT IS A “MACRO,” ANYWAY?
Back in the day, a programming language was often called a “macro language” if its
capabilities included the automation of a sequence of commands in spreadsheet or
word-processing applications. With Microsoft’s release of Offi ce 5, VBA set a new
bar for how robust a programming language can be, with capabilities extending far
beyond those of earlier programming languages, such as the ability to create and
control objects within Excel or to have access to disk drives and networks.

1
continues

4 ❘ LESSON 1 INTRODUCING VBA


So VBA is a programming language, and it is also a macro language. Confusion
of terminology arises when referring to VBA code that is a series of commands
written and executed in Excel. Is it a macro, a procedure, or a program? Microsoft
commonly refers to its VBA procedures as macros, so that’s good enough for me
to call them macros also. Outside of a few exceptions that I explain when the time
comes, I refer to VBA procedures as macros.
A BRIEF HISTORY OF VBA
VBA is a present-day dialect of the BASIC (Beginner’s All-purpose Symbolic Instruction Code)
programming language that was developed in the 1960s. BASIC became widely used in many
software applications throughout the next two decades because it was easy to learn and understand.
Over the years, BASIC has evolved and improved in response to advancing technology and increased
demands by its users for greater programming fl exibility. In 1985, Microsoft released a much
richer version of BASIC, named QuickBASIC, which boasted the most up-to-date features found in
programming languages of the day. In 1992, Microsoft released Visual Basic for Windows, designed
to work within the burgeoning Windows environment.
Meanwhile, various software publishers were making their own enhancements to BASIC for their
products’ programming languages, resulting in a wide and confusing range of functionality and
commands among software applications that were using BASIC. Microsoft recognized the need
for developing a standardized programming language for its software products, and created Visual
Basic for Applications.
VBA was fi rst released by Microsoft with Excel 5 in the Offi ce 1995 suite. Since then, VBA has
become the programming language for Microsoft’s other popular Offi ce applications, as well as for
external software customers of Microsoft to whom VBA has been licensed for use.
THERE’S A BIG DIFFERENCE BETWEEN VB AND VBA!
With all the acronyms bandied about in the world of computing, it’s easy to get
some terms confused. VB stands for Visual Basic, and it is not the same as VBA.
Though both VB and VBA are programming languages derived from BASIC and
created by Microsoft, they are otherwise very different.
VB is a language that enables you to create standalone executable applications that
do not even require its users to have Offi ce or Excel loaded onto their computers.
VBA cannot create standalone applications, and it exists within a host application
such as Excel and the workbook containing the VBA code. For a VBA macro to
run, its host application workbook must be open. This book is about VBA and how
it controls Excel.
continued

What VBA Can Do for You ❘ 5


WHAT VBA CAN DO FOR YOU
Everyone reading this book uses Excel for their own needs, such as fi nancial budgeting, forecasting,
analyzing scientifi c data, creating invoices, or charting the progress of their favorite football team.
One thing all readers have in common is the need to automate some kind of frequently encountered
task that is either too time-consuming or too cumbersome to continue doing manually. That’s where
VBA comes in.
The good news is that utilizing VBA does not mandate that you fi rst become a world-class
professional programmer. Many VBA commands are at your disposal, and are relatively easy to
implement and customize for your everyday purposes.
Anything you can do manually you can do with VBA, but VBA enables you to do it faster and with a
minimized risk of human error. Many things that Excel does not allow you to do manually, you can
do with VBA. The following sections describe a handful of examples of what VBA can do for you.
Automating a Recurring Task
If you fi nd yourself needing to produce weekly or monthly sales and expense reports, a macro can
create them in no time fl at, in a style and format you (and more importantly, your boss) will be
thrilled with. And if the source data changes later that day and you need to produce the updated
report again, no problem—just run the macro again!
Automating a Repetitive Task
When faced with needing to perform the same task on every worksheet in your workbook, or in
every workbook in a particular fi le folder, you can create a macro to “loop” through each object
and do the deed. You fi nd out how to repeat actions with various looping methods in Lesson 10.
Figure 1-1 shows an example of worksheets that were sorted in alphabetical order by a macro that
looped through each tab name, repositioning each sheet in the process.
Running a Macro Automatically if Another Action Takes Place
In some situations, you want a macro to run automatically so you don’t have to worry about
remembering to run it yourself. For example, to automatically refresh a pivot table the moment
its source data changes, you can monitor those changes with VBA, ensuring that your pivot table
always displays real-time results. This is called “event” programming, which is cool stuff, and is
discussed in Lessons 13 and 14.
An event can also be triggered and programmed anytime a cell or range of cells is selected. A common
request I’ve received from Excel users is to highlight the active cell, or the row and column
belonging to the active cell, automatically when a cell is selected. Figure 1-2 shows three options to
easily locate your active cell as you traverse your worksheet.

You might also like