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
|
Private Sub UserForm_Activate()
ActiveSheet.Unprotect
Dim y As Integer, i As Integer, tabl() As Variant, j as integer
OptionButton1.Value = True
y = 2: i = 1
While Sheets("feuil1").Cells(y, 11) <> ""
ReDim Preserve tabl(i)
tabl(i) = Sheets("feuil1").Cells(y, 11) 'A ce moment la, la macro cherche toutes les valeurs dans la colonne K jusqu'à "" puis les insère dans la combobox
y = y + 1: i = i + 1
Wend
ComboBox1.Clear
For i = 0 To UBound(tabl())
ComboBox1.AddItem tabl(i)
Next i
y = 2: j = 1
While Sheets("feuil1").Cells(y, 12) <> ""
ReDim Preserve tabl(j)
tabl(j) = Sheets("feuil1").Cells(y, 12) ' Il fait de même avec la colonne L
y = y + 1: j = j + 1
Wend
ComboBox1.Clear
For j = 0 To UBound(tabl())
ComboBox1.AddItem tabl(j)
Next j
ActiveSheet.Protect
End Sub |
Partager