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
| Dim Dico As Object
Private Sub Bt_Valider_Click()
'Private Sub CommandButton1_Click()
Dim I As Integer, y As Integer
With Me.ListBox1
For I = 0 To .ListCount - 1
If .Selected(I) = True Then
y = y + 1
Range("A" & y).Value = .List(I)
End If
Next I
End With
With Me.ListBox2
For I = 0 To .ListCount - 1
If .Selected(I) = True Then
y = y + 1
Range("a" & y).Value = .List(I)
End If
Next I
End With
With Me.ListBox3
For I = 0 To .ListCount - 1
If .Selected(I) = True Then
y = y + 1
Range("a" & y).Value = .List(I)
End If
Next I
End With
End Sub
Private Sub CommandButton2_Click()
Dim I As Integer
With Me.ListBox1
For I = 0 To .ListCount - 1
If .Selected(I) = True Then
[C1] = [C1] & " " & .List(I)
End If
Next I
End With
End Sub
Private Sub CommandButton1_Click()
Unload UserForm1
End Sub
Private Sub ListBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim C As Range, Ligne As Long
' Dico.RemoveAll
With Feuil2
Var = Dico.keys
For I = 0 To Me.ListBox2.ListCount - 1
If Me.ListBox2.Selected(I) Then
For Each C In .Range("C1", .Cells(.Rows.Count, 3).End(xlUp))
For j = 1 To UBound(Var)
If C.Value = Me.ListBox1.List(I) And Split(Var(j), "|")(0) = C.Value And _
Split(Var(j), "|")(1) = C.Offset(, 1).Value Then
Me.ListBox3.AddItem C.Offset(, 2).Value
End If
Next j
Next C
End If
Next I
End With
End Sub
Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim C As Range, Ligne As Long
With Feuil2
.[F:G].ClearContents
For I = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(I) Then
For Each C In .Range("C1", .Cells(.Rows.Count, 3).End(xlUp))
If C.Value = Me.ListBox1.List(I) Then
If Not Dico.exists(C.Value & "|" & C.Offset(, 1).Value) Then
Dico.Add C.Value & "|" & C.Offset(, 1).Value, C.Value & "|" & C.Offset(, 1).Value
Me.ListBox2.AddItem C.Offset(, 1).Value
End If
End If
Next C
End If
Next I
End With
End Sub
Private Sub UserForm_Initialize()
Set Dico = CreateObject("Scripting.Dictionary")
End Sub |
Partager