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 14. UserForm Examples

In This Chapter

This chapter presents many useful and informative examples that introduce you to some additional techniques that involve UserForms.

  • Using a UserForm for a simple menu

  • Selecting ranges from a UserForm

  • Using a UserForm as a splash screen

  • Changing the size of a UserForm while it’s displayed

  • Zooming and scrolling a sheet from a UserForm

  • Understanding various techniques that involve a ListBox control

  • Using an external control

  • Using the MultiPage control

  • Animating a Label control

You might be able to adapt these techniques to your own work. All the examples are available on the CD-ROM that accompanies this book.

Cross-Reference

Cross-Reference

Chapter 15 contains additional examples of more advanced UserForm techniques.

Creating a UserForm “Menu”

Sometimes, you might want to use a UserForm as a type of menu. In other words, the UserForm presents some options, and the user makes a choice. This section presents two ways to do this: using CommandButtons or using a ListBox.

Using CommandButtons in a UserForm

Figure 14-1 shows an example of a UserForm that uses CommandButton controls as a simple menu. Setting up this sort of thing is very easy, and the code behind the UserForm is very straightforward. Each CommandButton has its own event handler procedure. For example, the following procedure is executed when CommandButton1 is clicked:

Figure 14-1. This dialog box uses CommandButtons ...

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