O'Reilly logo

Excel® 2007 Power Programming with VBA by John Walkenbach

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 29. Understanding Class Modules

In This Chapter

This chapter presents an introduction to class modules and includes several examples that might help you better understand this feature and give you ideas for using class modules in your own projects.

  • An introduction to class modules

  • Some typical uses for class modules

  • Examples that demonstrate some key concepts related to class modules

For many VBA programmers, the concept of a class module is a mystery, even though this feature has been available in Visual Basic for several years — it was added to Excel beginning with Excel 97. The examples in this chapter may help to make this powerful feature less mysterious.

What Is a Class Module?

A class module is a special type of VBA module that you can insert into a VBA project. Basically, a class module enables the programmer (you) to create a new object class. As you should know by now, programming Excel really boils down to manipulating objects. A class module allows you to create new objects, along with corresponding properties, methods, and events.

Cross-Reference

Cross-Reference

Examples in previous chapters in this book use class modules. See Chapters 15, 18, 19, and 22.

At this point, you might be asking, “Do I really need to create new objects?” The answer is no. You don’t need to, but you might want to after you understand some of the benefits of doing so. In many cases, a class module simply serves ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required