Forms Controls: Group Boxes and Option Buttons

plwhittington

Board Regular
Joined
May 10, 2007
Messages
132
Using VBA, I am creating a sheet with two Group Boxes (Forms Controls)- each Group Box has two Option Buttons. Can someone tell me how to keep all four of the option buttons from all being linked/grouped?

I want the user to make two selections on the sheet- one option button selected in each group box. Right now, only one of the option buttons can be selected at a time.

Can someone tell me how to make the one group of four buttons two groups of two?

I have tried linking two to one cell and two to another, but didn't help. They all link to the last cell I selected.

______________________________________________________________________
Below is the code I am using:

'GROUP BOX 1
With ActiveSheet.GroupBoxes.Add(20, 10, 85, 40)
.Name = "Group Box 1"
ActiveSheet.GroupBoxes("Group Box 1").Caption = "Report Selection"
End With

'OPTION BUTTON 1
With ActiveSheet.OptionButtons.Add(25.5, 13, 93, 22)
.Name = "Option Button 1"
.OnAction = "A7ReportCriteria"
.Caption = "Summary"
End With

'OPTION BUTTON 2
With ActiveSheet.OptionButtons.Add(25.5, 28, 93, 17.25)
.Name = "Option Button 2"
.OnAction = "A7ReportCriteria"
.Caption = "Detail"
End With


'GROUP BOX 2
With ActiveSheet.GroupBoxes.Add(105, 10, 85, 40)
.Name = "Group Box 2"
ActiveSheet.GroupBoxes("Group Box 2").Caption = "Sort"
End With

'OPTION BUTTON 3
With ActiveSheet.OptionButtons.Add(110.5, 13, 93, 22)
.Name = "Option Button 3"
.OnAction = "A8ReportCriteria"
.Caption = "by Seller"
End With
End If

'OPTION BUTTON 4
With ActiveSheet.OptionButtons.Add(110.5, 28, 93, 17.25)
.Name = "Option Button 4"
.OnAction = "A8ReportCriteria"
.Caption = "by Partner"
End With




Thanks.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Make sure each Option Button control fits entirely within the GroupBox. In your current code, the width (93) of each Option Button exceeds the width of the GroupBox (85)
 
Upvote 0
Wow- can't believe it was that simple and impressed you were able to identify it so fast. Thanks- I made the changes and it's working now.
 
Upvote 0

Forum statistics

Threads
1,203,483
Messages
6,055,679
Members
444,807
Latest member
RustyExcel

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
Back
Top