A radio button is a Windows control made of a round box
O. The user makes his or her decision by selecting or clicking the round
box. Actually, a radio button is usually, if not always accompanied by
others. Such radio buttons appear and behave as a group. The user decides
which button is valid by selecting only one of them. When the user clicks
one button, its round box fills with a (big) dot: 8.
When one button in the group is selected, the other round buttons of the
(same) group are empty. The user can select another button by clicking a
different choice, which empties the previous selection. This technique of
selecting is referred to as mutually-exclusive. 8.
For this reason, and based on this behavior, a radio button is also called
an option button.
To implement radio buttons in Microsoft Excel, you can
start by including either the rectangle from the Drawing toolbar or the Group
Box control from the Forms toolbar. Any of these two objects would
serve as the delimiter of the group. After adding one of these shapes, you
can then add two or more radio buttons by using the Option Button control
from the Forms toolbar
|
Practical Learning: Printing an Invoice |
|
- Start Microsoft Excel with its default workbook or create a new
workbook
- To start a form, on the main menu, click View -> Toolbars ->
Forms
- On the Forms toolbar, click the Group Box and draw a rectangle on
the worksheet
- Type Pizza Size Selection
- On the Forms toolbar, click Option Button and click inside the Group
Box just under Pizza Size Selection
- Type Small
- From the Forms toolbar again, click Option Button and click inside
the Group Box under the first radio button
- Type Medium
- Once again on the Forms toolbar, click Option Button and click
inside the Group Box under the previous radio button
- Type Large
- Complete the design of the form as follows:
- To create a procedure for each radio button, on the main menu, click
Tools -> Macro -> Visual Basic Editor
- Type the following:
Sub SelectSmall()
Range("D10").Value = "=R[-6]C"
End Sub
Sub SelectMedium()
Range("D10").Value = "=R[-4]C"
End Sub
Sub SelectLarge()
Range("D10").Value = "=R[-2]C"
End Sub
|
- Close Visual Basic
- On the worksheet, right-click the Small radio button and click
Assign Macro
- In the Assign Macro dialog box, in the Macro Name list, click
SelectSmall
- Click OK
- Right-click the Medium radio button and click Assign Macro
- In the Assign Macro dialog box, click SelectMedium and click OK
- Right-click the Large radio button and click Assign Macro
- In the Assign Macro dialog box, click SelectLarge and click OK
- Click any cell to deselect
- Test each radio button
|
|
|