1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Private Sub UserForm_Initialize()
Com1
Com2
End Sub
Private Sub Com1()
Dim Obj As Control, c As Range, V As New Collection, Cl1 As Classe2, i As Integer, toto As String
Set Collect1 = New Collection
On Error Resume Next
Application.ScreenUpdating = False
For Each c In Range("c7", [c65000].End(xlUp))
If c <> "" Then V.Add c.Value, CStr([c])
Next c
For i = 1 To V.Count
Set Obj = Controls.Add("forms.Checkbox.1")
With Obj
.GroupName = "client"
.Name = "moncheckbox" & i
.Object.Caption = V.Item(i)
.Left = 10
.Top = 30 * i + 10
.Width = 50
.Height = 20
End With
Set Cl1 = New Classe2
Set Cl1.ChkBx1 = Obj
Collect1.Add Cl1
Next i
End Sub
Private Sub Com2()
Dim Obj As Control, c As Range, V As New Collection, Cl As Classe1, i As Integer, toto As String
Set Collect = New Collection
On Error Resume Next
Application.ScreenUpdating = False
For Each c In Range("d7", [d65000].End(xlUp))
If c <> "" Then V.Add c.Value, CStr([c])
Next c
For i = 1 To V.Count
Set Obj = Controls.Add("forms.Checkbox.1")
With Obj
.GroupName = "product"
.Name = "moncheckbox" & i
.Object.Caption = V.Item(i)
.Left = 90
.Top = 30 * i + 10
.Width = 50
.Height = 20
End With
Set Cl = New Classe1
Set Cl.ChkBx = Obj
Collect.Add Cl
Next i
End Sub |
Partager