Page 24 - Excel for Scientists and Engineers: Numerical Methods
P. 24

Chapter 1




                                                       Introducing


                 Visual Basic for Applications




                   In  addition  to  Excel's  extensive  list  of  worksheet  functions  and  array  of
               calculation  tools  for  scientific  and  engineering  calculations,  Excel  contains  a
               programming  language  that  allows  users  to  create  procedures,  sometimes
               referred to as macros, that can perform even more advanced calculations or that
               can automate repetitive calculations.
                   Excel's first programming  language, Excel  4 Macro Language (XLM) was
               introduced with version 4 of Excel.  It was a rather cumbersome language, but it
               did provide most of the capabilities of a programming language, such as looping,
               branching and so on.  This first programming language was quickly superseded
               by  Excel's  current  programming  language,  Visual  Basic  for  Applications,
               introduced with version 5  of Excel.  Visual Basic for Applications, or VBA, is a
                "dialect" of Microsoft's Visual  Basic programming  language, a dialect that  has
               keywords to allow the programmer to work with Excel's workbooks, worksheets,
               cells, charts, etc.  At the  same time, Microsoft  introduced  a version  of Visual
               Basic  for  Word;  it  was  called  WordBasic  and  had  keywords  for  characters,
               paragraphs,  line  breaks,  etc.  But  even  at  the  beginning,  Microsoft's  stated
                intention was to have one version  of Visual  Basic that  could work with  all  its
                applications: Excel, Word, Access and PowerPoint.  Each version of Microsoft
                Office has moved closer to this goal.



                The Visual Basic Editor
                   To create VBA code, or to examine existing code, you will need to use the
                Visual Basic Editor.  To access the Visual Basic Editor, choose Macro from the
                Tools menu and then Visual Basic Editor from the submenu.
                   The Visual Basic Editor  screen usually  contains three  important windows:
                the Project Explorer window, the Properties window and the Code window, as
                shown in Figure 1-1.  (What you see may not look exactly like this.)
                   The Code window displays the active module sheet; each module sheet can
                contain one or several VBA procedures.  If the workbook you are using does not





                                                   1
   19   20   21   22   23   24   25   26   27   28   29