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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
Private Sub CommandButton4_Click()
Dim cbox As MSForms.ComboBox
Dim Txt As MSForms.TextBox
Dim ctrl As Control
Dim I As Integer
For Each ctrl In Controls
If ctrl.Name Like "ref*" Then I = I + 1
Next
Feuil6.Cells(1, 8).Value = I
Set cbox = Me.Controls.Add("Forms.Combobox.1")
With cbox
.Name = "ref" & I
.Left = 20
.Top = 60 + ((I + 1) * 22)
.Width = 100
.Height = 15.5
.RowSource = "'LISTES'!A1: A153" ' récupère les info à mettre dans le cmbobox
Me.Height = .Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au nb de combobox
CheckBox1.Top = Me.Height - 45 'permet de placer le bouton sous les combobox
Label8.Top = Me.Height - 45
CommandButton1.Top = Me.Height - 30
CommandButton2.Top = Me.Height - 30
CommandButton3.Top = Me.Height - 30
Me.Height = CommandButton1.Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au bouton
End With
Set cbox = Me.Controls.Add("Forms.Combobox.1")
With cbox
.Name = "taille" & I
.Left = 120
.Top = 60 + ((I + 1) * 22)
.Width = 40
.Height = 15.5
.RowSource = "'LISTES'!C1: C44" ' récupère les info à mettre dans le cmbobox
Me.Height = .Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au nb de combobox
CheckBox1.Top = Me.Height - 45 'permet de placer le bouton sous les combobox
Label8.Top = Me.Height - 45
CommandButton1.Top = Me.Height - 30
CommandButton2.Top = Me.Height - 30
CommandButton3.Top = Me.Height - 30
Me.Height = CommandButton1.Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au bouton
End With
Set cbox = Me.Controls.Add("Forms.Combobox.1")
With cbox
.Name = "couleur" & I
.Left = 160
.Top = 60 + ((I + 1) * 22)
.Width = 65
.Height = 15.5
.RowSource = "'LISTES'!D1: D34" ' récupère les info à mettre dans le cmbobox
Me.Height = .Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au nb de combobox
CheckBox1.Top = Me.Height - 45 'permet de placer le bouton sous les combobox
Label8.Top = Me.Height - 45
CommandButton1.Top = Me.Height - 30
CommandButton2.Top = Me.Height - 30
CommandButton3.Top = Me.Height - 30
Me.Height = CommandButton1.Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au bouton
End With
Set Txt = Me.Controls.Add("Forms.textbox.1")
With Txt
.Name = "qt" & I
.Left = 225
.Top = 60 + ((I + 1) * 22)
.Width = 35
.Height = 15.5
Me.Height = Txt.Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au nb de combobox
CheckBox1.Top = Me.Height - 45 'permet de placer le bouton sous les combobox
Label8.Top = Me.Height - 45
CommandButton1.Top = Me.Height - 30
CommandButton2.Top = Me.Height - 30
CommandButton3.Top = Me.Height - 30
Me.Height = CommandButton1.Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au bouton
End With
Set cbox = Me.Controls.Add("Forms.Combobox.1")
With cbox
.Name = "motif" & I
.Left = 260
.Top = 60 + ((I + 1) * 22)
.Width = 100
.Height = 15.5
.RowSource = "'LISTES'!B1: B6" ' récupère les info à mettre dans le cmbobox
Me.Height = .Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au nb de combobox
CheckBox1.Top = Me.Height - 45 'permet de placer le bouton sous les combobox
Label8.Top = Me.Height - 45
CommandButton1.Top = Me.Height - 30
CommandButton2.Top = Me.Height - 30
CommandButton3.Top = Me.Height - 30
Me.Height = CommandButton1.Top + .Height + 50 ' permet d'ajuster la dimension de l'userform au bouton
End With
I = 0 '<<< évite la case vide
For Each ctrl In Me.Controls
If TypeName(ctrl) = "ComboBox" Then '<<< Attention à la casse !!! ComboBox différent de combobox
I = I + 1
ReDim Preserve MesComboBox(1 To I)
Set MesComboBox(I).groupecombobox = ctrl
End If
Next ctrl
I = 0
For Each ctrl In Me.Controls
If TypeName(ctrl) = "TextBox" Then
I = I + 1
ReDim Preserve MesTexBox(1 To I)
Set MesTexBox(I).groupetextbox = ctrl
End If
Next ctrl
End Sub |
Partager