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
|
Option Explicit
Private Sub UserForm_Initialize()
Dim Noms As Object
Dim Cel As Range
Set Noms = CreateObject("Scripting.Dictionary")
For Each Cel In Range("A2:A" & [A65000].End(xlUp).Row)
'If Cel.Offset(0, 6).Value <> "" Then Noms.Item(Cel.Value) = Cel.Value
Noms.Item(Cel.Value) = Cel.Value
Next Cel
Me.ComboBox1.List = Application.Transpose(Noms.Items)
End Sub
Private Sub ComboBox1_Change()
Dim Lig As Long
Dim Nbr As Byte, i As Byte
Lig = Application.Match(Me.ComboBox1, Columns(1), 0)
If Cells(Lig, 7).Value <> "" Then
Nbr = Application.CountIf(Columns(1), Me.ComboBox1)
Cells(Lig, 7).Resize(Nbr, 1).Name = "base"
With Me.ListBox1
.Clear
.ColumnCount = 2
For i = 1 To Nbr
.AddItem
.List(i - 1, 0) = Range("base")(i).Value
.List(i - 1, 1) = Range("base")(i).Offset(0, 1).Value
Next i
End With
End If
Me.TextBox2.Value = Nbr * 1
End Sub |