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
| Option Explicit
Option Base 1
Option Compare Text
Dim a1$, a2$, a3$, a4$, a5$
Dim DerniereLigne As Long
Private Sub C1_Change() ' Combobox n° PR de l'userform dans recherche
If C1 = "" Then C1_Click
End Sub
Private Sub C2_Change() ' Combobox Date exp PR de l'userform dans recherche
If C2 = "" Then C1_Click
End Sub
Private Sub C3_Change() ' Combobox FICHE CONSIGNE de l'userform dans recherche
If C3 = "" Then C1_Click
End Sub
Private Sub C4_Change() ' Combobox date exp FICHE CONSIGNE de l'userform dans recherche
If C4 = "" Then C1_Click
End Sub
Private Sub C5_Change() ' Combobox Référence de l'userform dans recherche
If C5 = "" Then C1_Click
End Sub
Private Sub C1_Click() ' Combobox Entité de l'userform dans recherche
Dim I&, Fin&, y&, a&, AA
Application.ScreenUpdating = False
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
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
1 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 = "60;300;100;300;60" 'largeur des champs dans la listbox L1
.List = bb
End With
End Sub
Private Sub C2_Click() ' Combobox Direction de l'userform dans recherche
C1_Click
End Sub
Private Sub C3_Click() ' Combobox Service de l'userform dans recherche
C1_Click
End Sub
Private Sub C4_Click() ' Combobox Référence AT de l'userform dans recherche
C1_Click
End Sub
Private Sub C5_Click() ' Combobox Date AT de l'userform dans recherche
C1_Click
End Sub
Private Sub UserForm_Initialize()
Dim k As Byte
L1.ZOrder 1
For k = 1 To 5
Remplissage Me.Controls("C" & k), k
Next k
End Sub
Private Sub Remplissage(ByVal Cmb As Object, ByVal Col As Integer)
Dim Fin As Long, I As Long
Dim MonDico As Object
Dim AA
With Worksheets("Liste")
.AutoFilterMode = False
Fin = .Cells(.Rows.Count, 1).End(xlUp).Row
AA = .Range("A2:AH" & Fin)
End With
Set MonDico = CreateObject("Scripting.Dictionary")
For I = 1 To UBound(AA, 1)
If AA(I, Col) <> "" Then
If Not MonDico.Exists(AA(I, Col)) Then MonDico.Add AA(I, Col), AA(I, Col)
End If
Next I
If MonDico.Count > 0 Then Cmb.List = Application.Transpose(MonDico.Items)
MonDico.RemoveAll
Set MonDico = Nothing
End Sub |
Partager