View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Loop for check boxes

Just to add -

As Nick suggests OptionButtons work like Radio-buttons, press one and all
others are off. With ActiveX OptionButtons (looks like you have aX
Checkboxes) you can have sets of mutually exclusive OB's by assigning the
GroupName property to suit.

In Design mode, click properties and change GroupName's to suit.

Here's some code to make a new set of 20 sets of 4 optionbuttons

Suggest do not run this code in the same project of the activesheet. Also do
not "break" or step into the code.

Sub AddOBs()
Dim ole As OLEObject
Dim i As Long, j As Long

For i = 1 To 20
For j = 1 To 4
Set ole = ActiveSheet.OLEObjects.Add("Forms.OptionButton.1")

With ole
.Left = (j - 1) * 150 + 10
.Top = (i - 1) * 50 + 10
.Name = "OB_" & i & "_" & j
.Object.GroupName = "Set_" & i
.Object.Caption = "Set " & i & " Choice " & j
End With
Next
Next

End Sub


Regards,
Peter T





If you go with Nick's suggestion (and probably you should), you can

"NickH" wrote in message
...
Hi Karissa,

If you use OptionButtons, rather than CheckBoxes, this behaviour will
be automatic.

Put OptionButtons within unique Frames to get them to behave as a
group.

Let me know if I've misunderstood you.

Br,
NickH