Choosing and Placing Controls

The first step in using a control on a worksheet, chart sheet, or dialog sheet is choosing the control from the Forms toolbar and placing it on the sheet.

To place a control on a sheet

1. On the Forms toolbar, click the button for the control you want to add.

2. Click on the sheet, and drag until the control's outline is the size and shape you want.

The following table describes the control created by each button on the Forms toolbar.

Button

Description of control

Label

Text you provide for the user, including names, instructions, and cautions.

Edit Box

A box where a user can enter text, numbers, or cell references.

Group Box

A border containing a group of option buttons or other controls.

Create Button

A command button such as the OK or Cancel button.

bshbruce hale

Check Box

A box that indicates whether an option is set, regardless of the state of other options in the dialog box.

Option Button

A button for selecting one of a group of mutually exclusive options. Place a series of option buttons in a group box to group them.

List Box

A list of text strings, one or more of which can be selected.

Drop-Down

An uneditable text box and an arrow, paired with a drop-down list box that appears when the user clicks the arrow.

Combination List-Edit

An editable text box combined with a list box.

Combination Drop-Down Edit

An empty edit box and an arrow, paired with a drop-down list box that appears when the user clicks the arrow.

Scroll Bar

A horizontal or vertical scroll bar for changing numeric values. To create a horizontal scroll bar, size the scroll bar so that it's wider than it is high.

Spinner

A pair of buttons for incrementing or decrementing a displayed value.


The Forms toolbar contains four additional buttons for working with controls on dialog boxes, as described in the following table.

Button

Description

Control Properties

Used to view or change the properties belonging to the selected object; equivalent to clicking Object on the Format menu.

Edit Code

Used to create or edit code assigned to the selected object.

Toggle Grid

Used to align controls on a grid.

Run Dialog

Used to display the dialog box as it appears when it's run.


You can also add a control using the Add method for the appropriate control collection. Arguments for the Add method specify the position of the upper-left corner of the control and its height and width. The following example places a new button on the worksheet named "sheet1."


Worksheets("sheet1").Buttons.Add 50, 25, 100, 20

On a worksheet or chart sheet, you specify the coordinates of the upper-left corner of the control relative to the upper-left corner of the sheet. On a dialog sheet, you specify the coordinates of the upper-left corner of the control relative to the upper-left corner of the dialog frame. For more information, see "Add method" in Help.