View Full Version : optionbuttons and vba
RoadDog83
10-22-2009, 06:27 PM
so i have 3 optionbuttons and one command button on sheet 1 what i want to do is launch a different form depending on which option is selected. the problem i am having is that i dont know how to refer to these optionbuttons with vba. it seems to be different since they are on the worksheet instead of on a userform i cant rename them. any ideas on how to do this?
Greetings,
What type of option buttons? Are they from the Forms toolbar, or are they ActiveX controls from the Control Toobox?
Mark
RoadDog83
10-22-2009, 06:45 PM
guess i should have specified that. i believe they are the "legacy" controls they are not the active x controls
Okay, if I understand, this might work:
Sub Button5_Click()
With Sheet1
If .OptionButtons("Option Button 2") = 1 Then
UserForm1.Show
ElseIf .OptionButtons("Option Button 3") = 1 Then
UserForm2.Show
ElseIf .OptionButtons("Option Button 4") = 1 Then
UserForm3.Show
Else
MsgBox "nothing selected"
End If
End With
End Sub
You mentioned not being able to rename the option button. I think you should be able to do this in the name box?
Mark
Bob Phillips
10-23-2009, 03:27 AM
... i cant rename them ...
You can.
Select the button, then type the new name in the names box, to the left of the formula bar.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.