Page 32 - Excel Progamming Weekend Crash Course
P. 32

d540629 ch01.qxd  9/2/03  9:27 AM  Page 7




                  Session 1 — Microsoft Excel Programming — Why and How                    7

               Creating Instructions

               Programming is really nothing more than creating instructions that tell the computer what
               to do. In an office, for example, you might ask your assistant to make copies — that’s an
               instruction. A computer program is the same — you tell the computer what to do. The
               primary difference is that computers are really dumb and can’t figure out the fine points
               on their own, so you must tell them exactly what to do in excruciating detail. Explicit
               instructions are at the heart of any program.
                  Some instructions manipulate data. This can be as simple as adding two numbers, or as
               complex as creating a chart. Other instructions control the execution of the program itself.
               For example, a program could be designed to perform one task on weekdays and another
               task on weekends. Still other instructions control how the program interacts with the user,
               such as how it responds to the user’s selections from a menu or dialog box.


               Handling Data
               Every computer program works with data. This data can come in many forms — text,
               numbers, and graphics — but for now you don’t need to be concerned with these details.
               A fundamental part of programming consists of handling the data that the program uses.
               You need a specific place to keep the data, and you also need to be able to get at the data
               when necessary. From this perspective, data can be divided into two categories:

                   Data stored outside the program. For the most part, this category comprises data
                   that is stored in the cells of an Excel worksheet. Your program does not need to
                   create storage for such data, although the program can read and write it.
                   Data stored within the program. For data that is not stored elsewhere, a program
                   needs to create a storage location. A program uses variables to store internal data.
                   As you’ll see in later sessions, Excel programming offers a wide range of internal
                   data storage capabilities.
                  When you are programming with Excel, the data-handling capabilities available to you
               are quite impressive. They provide a variety of data types that are specialized for storing
               different kinds of data. You learn more about these data types in later sessions.


               The VBA Language

               You will use the VBA language to write Excel programs. VBA stands for Visual Basic for
               Applications, and it is one of the two essential parts of Excel programming. The name Visual
               Basic for Applications reflects the fact that VBA is based on Microsoft’s Visual Basic program-
               ming language, and that it is designed for programming within applications — specifically,
               the applications that comprise the Microsoft Office suite (Excel, Word, Access, PowerPoint,
               and Outlook). VBA is relatively easy to learn, as programming languages go, but does not
               sacrifice power and flexibility.
                  The task of programming in VBA is simplified by the VBA Editor, which is part of your
               Excel installation. You can open the VBA Editor by pressing Alt+F11 when in Excel, or by
   27   28   29   30   31   32   33   34   35   36   37