Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add OptionButtons in Excel
Oli,
First, to have the two sets of two option buttons work as two independant groups, you should put each of the two option buttons inside a "frame" tool. This is the little box with XYX at the top in the VBA toolbox. You can change the name displayed on the frame by changing its Caption property. You will need to display the Properties window in VBA by pressing the F4 button. As you select a component on your userform (say Frame1), the properties window will display all the properties for that particular control. Second, you can change the captions of each of the option buttons by selecting the particular option button on the userform, then changing the Caption property again in the Properties window. If the current caption is OptionButton1, then double click on that name and type in whatever you want it to be (ex: change the Caption property from "OptionButton1" to "Add 10"). Third, you will need to provide the code to make each option button do its thing. Below is a very simple example for the code to make the first two option buttons work (selecting option 1 will add 10 to whatever the current cell value is, selecting option 2 will subtract 10 from the current cell value). Private Sub OptionButton1_Click() If OptionButton1 = True Then ActiveCell.Value = ActiveCell.Value + 10 End If End Sub Private Sub OptionButton2_Click() If OptionButton2 = True Then ActiveCell.Value = ActiveCell.Value - 10 End If End Sub Hopefully this gives you some ideas. You can change the code in each of the option buttons to cause the specific action you desire (i.e. change "ActiveCell.Value = ActiveCell.Value - 10" to whatever you need). Andrew Lenczycki -----Original Message----- Hi! I've got only few experiences in programming with VBA, because of that I've got several Problems with adding OptionButtons using VBA in an Excel Sheet. First: I would like to add 4 Option Buttons and give them different names (captions) Next: I would like do group them into 2 groups. After that: I would like to change values of different cells after the value of an optionbutton has changed. If there is somone out there, who could give me an example how to solve this I would be very pleased Thx Oli . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UserForm OptionButtons | Excel Discussion (Misc queries) | |||
Control ToolBox OptionButtons? | Excel Discussion (Misc queries) | |||
Moving OptionButtons | Excel Discussion (Misc queries) | |||
Need help creating a userform with optionbuttons | Excel Programming | |||
optionbuttons | Excel Programming |