# option button if functions

#### rodney_malodney

##### Board Regular
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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

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

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.

Replies
12
Views
307
Replies
2
Views
419
Replies
1
Views
174
Replies
1
Views
64
Replies
29
Views
569

1,196,388
Messages
6,014,995
Members
441,864
Latest member
sweezy40

### 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.

### Which adblocker are you using?

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

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