F
Flexx
Hello
I have a problem with my OptionButtons and my GroupBoxes.
In a form, which is a kind of survey, GroupBoxes and OptionButtons ar
automatically generated, depending on the number of questions.
Each OptionButton must fit in a cell, and a GroupBox has to include man
OptionButtons.
But there is a problem. Some OptionButtons are not included in th
GroupBox
So, it is possible to select more than one option button into the grou
!
You can see it on the following capture :
http://img15.hostingpics.net/pics/473486PbGroupBoxes.png
Or this one :
http://img15.hostingpics.net/pics/364359PbExcel.png
You can play with the attached file to see the problem.
Or use the following code :
Sub Bouton1_Clic()
Dim myCell As Range
Dim numCell As Integer
Dim myGroupBox As GroupBox
Dim myOptionButton As OptionButton
ActiveSheet.OptionButtons.Delete
ActiveSheet.GroupBoxes.Delete
numCell = 0
For Each myCell In ActiveSheet.Range("E2:E12").Cells
If numCell = 0 Then
Set myGroupBox = ActiveSheet.GroupBoxes.Add(myCell.Left
myCell.Top, myCell.Width, (myCell.Height * 3))
myGroupBox.Caption = ""
End If
numCell = numCell + 1
If numCell = 3 Then numCell = 0
Next
numCell = 0
For Each myCell In ActiveSheet.Range("E2:E13").Cells
Set myOptionButton = ActiveSheet.OptionButtons.Add(myCell.Left
myCell.Top, 5, 5)
myOptionButton.Caption = ""
Next
End Sub
Thanks a lot for your help
+-------------------------------------------------------------------
|Filename: PbOptionButton.zip
|Download: http://www.excelbanter.com/attachment.php?attachmentid=317
+-------------------------------------------------------------------
I have a problem with my OptionButtons and my GroupBoxes.
In a form, which is a kind of survey, GroupBoxes and OptionButtons ar
automatically generated, depending on the number of questions.
Each OptionButton must fit in a cell, and a GroupBox has to include man
OptionButtons.
But there is a problem. Some OptionButtons are not included in th
GroupBox
So, it is possible to select more than one option button into the grou
!
You can see it on the following capture :
http://img15.hostingpics.net/pics/473486PbGroupBoxes.png
Or this one :
http://img15.hostingpics.net/pics/364359PbExcel.png
You can play with the attached file to see the problem.
Or use the following code :
Sub Bouton1_Clic()
Dim myCell As Range
Dim numCell As Integer
Dim myGroupBox As GroupBox
Dim myOptionButton As OptionButton
ActiveSheet.OptionButtons.Delete
ActiveSheet.GroupBoxes.Delete
numCell = 0
For Each myCell In ActiveSheet.Range("E2:E12").Cells
If numCell = 0 Then
Set myGroupBox = ActiveSheet.GroupBoxes.Add(myCell.Left
myCell.Top, myCell.Width, (myCell.Height * 3))
myGroupBox.Caption = ""
End If
numCell = numCell + 1
If numCell = 3 Then numCell = 0
Next
numCell = 0
For Each myCell In ActiveSheet.Range("E2:E13").Cells
Set myOptionButton = ActiveSheet.OptionButtons.Add(myCell.Left
myCell.Top, 5, 5)
myOptionButton.Caption = ""
Next
End Sub
Thanks a lot for your help
+-------------------------------------------------------------------
|Filename: PbOptionButton.zip
|Download: http://www.excelbanter.com/attachment.php?attachmentid=317
+-------------------------------------------------------------------