Radio Buttons

Introduction

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

  1. Start Microsoft Excel with its default workbook or create a new workbook
  2. To start a form, on the main menu, click View -> Toolbars -> Forms
  3. On the Forms toolbar, click the Group Box and draw a rectangle on the worksheet
  4. Type Pizza Size Selection
  5. On the Forms toolbar, click Option Button and click inside the Group Box just under Pizza Size Selection
  6. Type Small
  7. From the Forms toolbar again, click Option Button and click inside the Group Box under the first radio button
  8. Type Medium
  9. Once again on the Forms toolbar, click Option Button and click inside the Group Box under the previous radio button
  10. Type Large
  11. Complete the design of the form as follows:
     
  12. To create a procedure for each radio button, on the main menu, click Tools -> Macro -> Visual Basic Editor
  13. 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
  14. Close Visual Basic
  15. On the worksheet, right-click the Small radio button and click Assign Macro
  16. In the Assign Macro dialog box, in the Macro Name list, click SelectSmall
     
  17. Click OK
  18. Right-click the Medium radio button and click Assign Macro
  19. In the Assign Macro dialog box, click SelectMedium and click OK
  20. Right-click the Large radio button and click Assign Macro
  21. In the Assign Macro dialog box, click SelectLarge and click OK
  22. Click any cell to deselect
  23. Test each radio button
 
 

Home Copyright 2004 FunctionX, Inc.