Chapter 14. VBA Overview and Basic Examples

In This Chapter

  • An overview of using Visual Basic for Applications (VBA) to manipulate charts

  • Macros to activate and deactivate charts

  • Macros to determine whether a chart is selected

  • Macros to count and loop through all charts

  • Macros to delete charts and print charts

This is the first of three chapters that deal with Visual Basic for Applications (VBA). VBA is Excel's programming language, and it is used to automate various aspects of Excel — including charts.

VBA in a Nutshell

VBA is Microsoft's common application scripting language. VBA is included with all Office 2007 applications, and it's also available in applications from other vendors. You use VBA to write procedures, frequently known as macros.

Note

This chapter assumes a basic familiarity with VBA. You should know how to use the VB Editor, enter code, execute procedures, and so on. If you have no experience using VBA, the material in this and the next two chapters will not make much sense. The remainder of this section presents a quick overview of VBA — useful as a refresher for those who haven't used VBA in a while. It's also useful to help novices decide whether learning VBA would be helpful.

Ready for the nutshell version of VBA? Here goes:

  • You perform actions in VBA by executing VBA code.

  • You write (or record) VBA code, which is stored in a VBA module.

  • VBA modules are stored in an Excel workbook, but you view or edit a module using the Visual Basic Editor.

  • A VBA module consists of procedures ...

Get Excel® 2007 Charts 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.