option button if functions

rodney_malodney

Board Regular
Joined
Jul 19, 2005
Messages
116
ok i do apologise for being a pain,

i have 6 option buttons on a userform, the user must select two, one from each page.

how can i do an if of the option buttons, i have this but it doesnt appear to work:

Code:
Private Sub CommandButton1_Click()


If optionbox6 = True Then
If optionbox7 = True Then
Range("b30") = "630.80"

Else: End If

If optionbox6 = True Then
If optionbox8 = True Then
Range("b30") = "785.40"

Else: End If

If optionbox6 = True Then
If optionbox9 = True Then
Range("b30") = "873.94"

Else: End If

If optionbox5 = True Then
If optionbox7 = True Then
Range("b30") = "791.83"

Else: End If

If optionbox5 = True Then
If optionbox8 = True Then
Range("b30") = "940.88"

Else: End If

If optionbox5 = True Then
If optionbox9 = True Then
Range("b30") = "1037.67"

Else: End If

If optionbox4 = True Then
If optionbox7 = True Then
Range("b30") = "813.81"

Else: End If

If optionbox4 = True Then
If optionbox8 = True Then
Range("b30") = "967.94"

Else: End If

If optionbox4 = True Then
If optionbox9 = True Then
Range("b30") = "1063.17"


'
End Sub
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

LwarenceD

New Member
Joined
Nov 24, 2005
Messages
29
I had some limited success in this area by using two Frames on a UserForm,

Place the first set of Option buttons in the first frame, and the second set in the second.

From what I see on your example, you'll want to place OptionBox4,5,6 in the first frame and OptionBox7,8,9 in the second Frame.

Cheers
lwrence
 

BJungheim

Well-known Member
Joined
Jul 24, 2004
Messages
914
You can group Option Buttons by first selecting the ones you want grouped (i.e. The first set of options) in the VBE and hit F4 for properties.

In the Properties window, give your first group of option buttons a GroupName. Do the same for the second group, but use a different name.

This will link the Option Buttons together, but keep them seperate from other Option Buttons on the form without the need for Frames.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,087
Messages
5,570,139
Members
412,306
Latest member
fabio6
Top