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
| Option Explicit
Option Base 1
Option Compare Text
Dim a1$, a2$, a3$, a4$, a5$
Private Sub C1_Change() ' Combobox référence de l'userform
If C1 = "" Then C1_Click
End Sub
Private Sub C2_Change() ' Combobox n° PR de l'userform
If C2 = "" Then C1_Click
End Sub
Private Sub C3_Change() ' Combobox Date exp PR de l'userform
If C3 = "" Then C1_Click
End Sub
Private Sub C4_Change() ' Combobox FICHE CONSIGNE de l'userform
If C4 = "" Then C1_Click
End Sub
Private Sub C5Change() ' Combobox date exp FICHE CONSIGNE de l'userform
If C5 = "" Then C1_Click
End Sub
Private Sub C1_Click() ' Combobox Référence de l'userform
Dim i&, fin&, y&, a&, aa
Application.ScreenUpdating = 0
If C1 = "" Then a1 = "*" Else a1 = C1
If C2 = "" Then a2 = "*" Else a2 = C2
If C3 = "" Then a3 = "*" Else a3 = C3
If C4 = "" Then a4 = "*" Else a4 = C4
If C5 = "" Then a5 = "*" Else a5 = C5
If a1 = "*" And a2 = "*" And a3 = "*" And a4 = "*" And a5 = "*" Then L1.Clear: Exit Sub
L1.Clear
With Feuil1 'feuille Appro
y = 2
fin = .Range("A" & Rows.Count).End(xlUp).Row
aa = .Range("A2:AH" & fin)
End With
For i = 1 To UBound(aa)
If aa(i, 1) Like a1 And aa(i, 2) Like a2 And aa(i, 3) Like a3 And aa(i, 4) Like a4 And aa(i, 5) Like a5 Then aa(i, 22) = "OUI": y = y + 1
Next i
If y = 1 Then Exit Sub
If y = 2 Then
ReDim bb(1, 2)
For i = 1 To UBound(aa)
If aa(i, 22) = "oui" Then
For a = 1 To 22
bb(1, a) = aa(i, a)
Next a
GoTo 1
End If
Next i
Else
ReDim bb(y - 1, UBound(aa, 2) - 1)
y = 1
For i = 1 To UBound(aa)
If aa(i, 22) = "OUI" Then
For a = 1 To 22
bb(y, a) = aa(i, a)
Next a
y = y + 1
End If
Next i
End If
With L1
.ColumnCount = 5 ' nombre de colonnes dans la list box L1
.ColumnWidths = "100;100;100;100;100" 'largeur des champs dans la listbox L1
.List = bb
End With
End Sub
Private Sub C2_Click() ' Combobox n° PR de l'userform
C1_Click
End Sub
Private Sub C3_Click() ' Combobox exp PR de l'userform
C1_Click
End Sub
Private Sub C4_Click() ' Combobox fiche consigne de l'userform
C1_Click
End Sub
Private Sub C5_Click() ' Combobox exp fiche consigne de l'userform
C1_Click
End Sub
Private Sub UserForm_Initialize()
Dim i&, fin&, aa, bb, mondico As Object
With Feuil1 'feuille Appro
fin = .Range("A" & Rows.Count).End(xlUp).Row
aa = .Range("A2:AH" & fin)
End With
Set mondico = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(aa)
If aa(i, 1) <> "" And Not mondico.exists(aa(i, 1)) Then mondico.Add aa(i, 1), aa(i, 1) ' indice 1 corresppond au champ réf
Next i
bb = Application.Transpose(mondico.items)
C1.List = bb
mondico.RemoveAll
For i = 1 To UBound(aa)
If aa(i, 2) <> "" And Not mondico.exists(aa(i, 2)) Then mondico.Add aa(i, 2), aa(i, 2) ' indice 2 corresppond au champ n° PR
Next i
bb = Application.Transpose(mondico.items)
C2.List = bb
mondico.RemoveAll
For i = 1 To UBound(aa)
If aa(i, 3) <> "" And Not mondico.exists(aa(i, 3)) Then mondico.Add aa(i, 3), aa(i, 3) ' indice 3 corresppond au champ exp PR
Next i
bb = Application.Transpose(mondico.items)
C3.List = bb
mondico.RemoveAll
For i = 1 To UBound(aa)
If aa(i, 4) <> "" And Not mondico.exists(aa(i, 4)) Then mondico.Add aa(i, 4), aa(i, 4) ' indice 4 corresppond au champ fiche consigne
Next i
bb = Application.Transpose(mondico.items)
C4.List = bb
mondico.RemoveAll
For i = 1 To UBound(aa)
If aa(i, 5) <> "" And Not mondico.exists(aa(i, 5)) Then mondico.Add aa(i, 5), aa(i, 5) ' indice 5 corresppond au champ exp fiche consigne
Next i
bb = Application.Transpose(mondico.items)
C5.List = bb
mondico.RemoveAll
End Sub |
Partager