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
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,995
Messages
5,834,779
Members
430,321
Latest member
yemisimi11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top