O'Reilly logo

Programming Excel with VBA and .NET by Steve Saunders, Jeff Webb

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

Use Controls on Worksheets

How is the Excel team like my mom? They never throw anything away. That was handy when I needed copies of my high school humor column, but it meant Mom’s house was a bit cluttered. In Excel’s case, it means you’ve got two toolbars full of similar-looking controls that you can use on a worksheet (Figure 20-16).

You can use Forms 1.0 or Forms 2.0 controls on a worksheet

Figure 20-16. You can use Forms 1.0 or Forms 2.0 controls on a worksheet

The Forms 1.0 controls are included mostly for backward-compatibility with earlier versions of Excel. They lack events and the full set of properties you get with Forms 2.0 controls. However, there are two items on the Forms toolbar that are very handy, so I will tell you how to add them to the Control Toolbox here:

  1. In Excel, choose View → Toolbars → Forms and View → Toolbars → Control Toolbox to display the two toolbars shown in Figure 20-16.

  2. Choose Tools → Customize to display the Customize dialog box and enable changes to the toolbars.

  3. Hold down the Ctrl key and click and drag the Toggle Grid from the Forms toolbar to the Control Toolbox. Excel copies the button onto the Control Toolbox.

  4. Repeat for the Button control, copying it from the Forms toolbar to the Control Toolbox.

  5. Close the Forms toolbar and never think of it again.

The Toggle Grid button turns a worksheet’s gridlines on and off. That helps create a cleaner appearance when you are using controls on a worksheet.

The ...

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