Chapter 22. Using the Visual Basic Editor

In This Chapter

  • Getting familiar with the Visual Basic Editor

  • Editing a macro in the Visual Basic Editor

  • Adding interactivity to a macro with a dialog box that processes user input

  • Creating and using user-defined functions in the Visual Basic Editor

  • Saving user-defined functions as Excel add-ins

Visual Basic for Applications (usually known simply as VBA) is the official programming language of Excel that you can use to edit as well as to write new macros. The key to editing and writing macros in Visual Basic for Applications is its editing program, the Visual Basic Editor (often abbreviated VBE). The Visual Basic Editor offers a rich environment for coding and debugging VBA code whose interface rivals that of Excel itself in terms of features and complexity.

In this chapter, you get a chance to practice using the Visual Basic Editor to edit macros that you've recorded (see Chapter 21) as well as to enhance their basic functionality through the addition of interactivity. In addition, you get practice using the VBE to create your own custom functions known as user-defined functions (often abbreviated UDF).

Using the Visual Basic Editor

You can open the Visual Basic Editor in one of three ways:

  • Click the Visual Basic button in the Code group at the very beginning of the Developer tab on the Ribbon (Alt+LV).

  • Press Alt+F11.

  • Open the Macro dialog box (Alt+F8), select a macro to edit, and then click the Edit button.

Figure 22-1 shows the arrangement of the ...

Get Excel® 2010 Workbook for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.