Главная » Excel Macros For Dummies читать онлайн | страница 53

Читать книгу Excel Macros For Dummies онлайн

53 страница из 60

If you followed the previous steps, you just created a VBA Sub procedure, also known as a macro. When you press F5, Excel executes the code and follows the instructions. In other words, Excel evaluates each statement and does what you told it to do. You can execute this macro any number of times — although it tends to lose its appeal after a few dozen executions.

This simple macro uses the following concepts:

 Defining a Sub procedure (the first line)

 Declaring variables (the Dim statements)

 Assigning values to variables (Msg and Ans)

 Concatenating (joining) a string (using the & operator)

 Using a built-in VBA function (MsgBox)

 Using built-in VBA constants (vbYesNo, vbNo, and vbYes)

 Using an If-Then construct (twice)

 Ending a Sub procedure (the last line)

Customizing the VBE

If you’re serious about becoming an Excel programmer, you’ll spend a lot of time with VBA modules on your screen. To help make things as comfortable as possible, the VBE provides quite a few customization options.

Правообладателям