CHAPTER 1

The Basics of VBA Programming

1.1 GETTING STARTED

To access the VBA editor, point to the Developer (VBA menu on the ribbon). In case this menu is not visible, proceed like this:

Office 2007 Click the Microsoft Office Button

image

then click on Excel Options (bottom right). Point to Popular and mark Show Developer tab in the Ribbon check box, then OK: the Developer tab is now displayed on the ribbon

Office 2010 and beyond Point the File menu and select Options

Click on Customize Ribbon, and mark Developer

image

When you click on Developer, Excel displays a minimum of three groups:

  • Code: this is the group from which you open the VBA editor
  • Controls: user interface components, to create Windows-like applications
  • XML: converts XML files into Excel files and vice versa.

From the Code group, click on “Visual basic” icon (far left). If you work on a newly created file, the VBA editor looks like this:

image

The bar on the top provides three especially useful menus:

  • View: a menu that lists windows editing information regarding the code execution. Also hides or shows the project explorer (on the left). At creation, the project reduces to three open sheets and an empty module named ThisWorkbook ...

Get How to Implement Market Models Using VBA 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.