PDA

View Full Version : How to relate. OPTION BUTTONS



_movenblvck_
03-23-2017, 05:37 AM
I've got a project about Excel.. In userform I need to have a group of option buttons .. Lets say 2 groups of optionbutton. Group1 has a 2 Option button and Group 2 has four.so i need to relate the group to have one ouput.

for example in Group1 a user chooses "ClassA" option button and that button would relate to the group2 option button and calculate a given formula


sorry for bad english.

_movenblvck_
03-23-2017, 05:41 AM
Lets say:
In Category I choose 10mm and in Class ui chhose Class A
so
10mm and Class A = Area * Formula1
10 mm and class B = Area * Formula 2
.
.
25mm and Class A = Area * Formula7
25mm and class B = Area * Formula 8
so how to relate each options

Paul_Hossler
03-23-2017, 11:36 AM
I think I understand the question

One way. You'll have to integrate your own logic / formula. I just used 's' to show the selections



Option Explicit
Private Sub CommandButton1_Click()
Dim s As String
With Me
If .OptionButton1 Then
If .OptionButton4 Then
s = "Selected " & OptionButton1.Caption & "-" & OptionButton4.Caption
ElseIf .OptionButton5 Then
s = "Selected " & OptionButton1.Caption & "-" & OptionButton5.Caption
End If
ElseIf .OptionButton2 Then
If .OptionButton4 Then
s = "Selected " & OptionButton2.Caption & "-" & OptionButton4.Caption
ElseIf .OptionButton5 Then
s = "Selected " & OptionButton2.Caption & "-" & OptionButton5.Caption
End If
ElseIf .OptionButton3 Then
If .OptionButton4 Then
s = "Selected " & OptionButton3.Caption & "-" & OptionButton4.Caption
ElseIf .OptionButton5 Then
s = "Selected " & OptionButton3.Caption & "-" & OptionButton5.Caption
End If
End If
End With


MsgBox s

End Sub

Private Sub UserForm_Initialize()
With Me
.OptionButton1 = True
.OptionButton4 = True
End With
End Sub