VisuAL Basic for Applications with Excel

In this first chapter, I introduce you to the programming tools available in Excel. These tools include the VBA IDE (Integrated Development Environment), controls and functions available through the main Excel application, and VBA on-line help. After your introduction to the VBA programming environment, I take you through a very short and simple program that calculates some basic statistics from a sample data set. The program displays the statistics in a worksheet formatted with a large font, bright colors, and a border to complete the Colorful Stats project.

Specifically this chapter will cover:

• Installing and enabling VBA

• The VBA IDE and components within

• Programming tools within Excel

Project: Colo^ul Stats

The project in this chapter is short and simple, but will serve as your first introduction to the VBA programming environment, ActiveX controls, event-driven programming, and using VBA to interact with your spreadsheet. A view of the Colorful Stats spreadsheet is shown in Figure 1.1.

In the Real World

Event-driven programming refers to the creation of a program that is designed to run when the user generates a stimulus. For example, a keystroke or a mouse click may trigger specific pieces of a program to execute. The event-driven programming model has been popular for years (since the first graphical-based operating systems such as Windows and Macintosh were introduced) and is now commonplace. It is vastly superior to older programs that did not allow for much user interaction because the programmers dictated the flow of the program. In event-driven programming, the user dictates the flow of the program and it is up to programmers to anticipate the user's needs.

The Colorful Stats project.

The Colorful Stats project.

Don't concern yourself with syntax (the rules of the VBA language) at this time. In subsequent chapters, I will show you the tools needed to build VBA projects. For right now, I just want you to see how easy it is to make something work and recognize that many of the keywords we use in VBA programming projects in this book are already familiar to you as an Excel user.

Keywords are words used by the programming Language for a special purpose and therefore are reserved. This means you cannot use a keyword in your program for anything other than what was designed into the language.

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment