This adds to a form with a scrollable frame 100 checkboxes.
Create a UserForm, Frame (Frame1), CommandButton (CommandButton1) and stick
the code behind the form:
Private Sub CommandButton1_Click()
Dim x As Integer, y As Integer
Dim chk As MSForms.CheckBox, dblBuffer As Double
Dim TopPos As Double, LeftPos As Double, OrigLeft As Double
Frame1.ScrollBars = fmScrollBarsBoth
' Adjust the initial left and top to adjust
' the initial starting (top left) starting point
OrigLeft = 5: TopPos = 5: LeftPos = OrigLeft
' Adjust the buffer to adjust the spacing between the controls
dblBuffer = 2
For x = 1 To 10
For y = 1 To 10
Set chk = Me.AddCheckbox(TopPos:=TopPos, LeftPos:=LeftPos,
Width:=15)
LeftPos = LeftPos + chk.Width + dblBuffer
Frame1.ScrollWidth = LeftPos + chk.Width
Next
TopPos = chk.Top + chk.Height + dblBuffer
LeftPos = OrigLeft
Frame1.ScrollHeight = chk.Top + chk.Height
Next
End Sub
Function AddCheckbox(ByVal TopPos As Double, ByVal LeftPos As Double, ByVal
Width As Double, _
Optional ByVal Height As Double = 18) As MSForms.CheckBox
Dim Ctrl As MSForms.CheckBox
Set Ctrl = Me.Frame1.Controls.Add("Forms.Checkbox.1", "")
With Ctrl
.Top = TopPos
.Left = LeftPos
.Width = Width
.Height = Height
End With
Set AddCheckbox = Ctrl
End Function