Using controls on worksheets
Detailed description of the controls (1)
The label control is the simplest control available, all it can be used for is to display descriptive text. Use this control if you want to add some explanatory text to another control.
TIP: You can make sure the label text is derived from a worksheet cell. To do so, select the label and then click in the formula bar and enter a reference to the cell. See fig. 5.
Fig 5: The text on a label drawn from a worksheet cell
You can use a frame to visually group controls with a shared purpose. Apart from that, the frame control has a specific function for option button controls (see the appropriate section about them). You must start with drawing the frame control before adding the controls you want placed "inside" the frame. To make this a painless process, start out by drawing a relatively large frame (you can make the frame smaller later on). After that, draw the controls inside the frame:
Fig 6: Frames with OptionButtons within.
Buttons or CommandButtons are used to start VBA code (macro's). If you draw a Button from the Forms toolbar on a sheet, Excel will prompt you for a macro to run when the button is clicked (fig 7). If you have not written a macro yet, then you can type the macro's name and click the "New" button to have the (empty) subroutine created for you:
Fig 7: Excel asks you what macro to run when the button is clicked.
If you used the CommandButton from the Control toolbox, you need to double-click the button (in design mode) to access its VBA click event. Code for control toolbox (ActiveX) controls is typically written in the code module behind the sheet they are placed on.
TIP: If you want to change the properties of a control from the control toolbox (an ActiveX control), then you must put your sheet into "Design mode". In Excel 2003 you can click the first button on the control toolbox toolbar. In Excel 2007 and up you can find this button on the "Developer" tab, within the "Controls" group. When you want to start using the controls, click the same button to get out of design mode.