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
| Private Sub ComboBox1_Change()
If ComboBox1.Text <> "" Then
Set f1 = Sheets("Etat")
Ref = ComboBox1.Text
Set f1 = Sheets("Etat")
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
DerLig = f1.[A10000].End(xlUp).Row
For Each c In f1.Range("A2.A" & DerLig)
If c = Ref * 1 Then
d1.Add c.Offset(0, 1).Value, c.Offset(0, 1).Value
d2.Add c.Offset(0, 2).Value, c.Offset(0, 2).Value
End If
Next c
ListBox1.List = Application.Transpose(d1.keys)
ListBox2.List = Application.Transpose(d2.keys)
End If
End Sub
Private Sub CommandButton1_Click()
Set f1 = Sheets("Etat")
Ref = ComboBox1.Text
DerLig = f1.[A10000].End(xlUp).Row
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Empl = ListBox1.List(ListBox1.ListIndex)
Exit For
End If
Next
With f1.Columns("A")
Set r = .Find(Ref, LookIn:=xlValues, lookat:=xlWhole)
If Not r Is Nothing Then
Posr = r.Address
Do
If f1.Cells(r.Row, "B") = Empl And f1.Cells(r.Row, "C") > 0 Then
f1.Cells(r.Row, "C") = f1.Cells(r.Row, "C") - 1
Unload PRISE_COMPOSANT
f1.Select
Exit Sub
End If
Set r = .FindNext(r)
Loop While Not r Is Nothing And r.Address <> Posr
End If
End With
Unload PRISE_COMPOSANT
f1.Select
End Sub |
Partager