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
|
Private Sub recherche() 'recherche multicritere
Dim lignedebut As Integer
Dim derniereligne As Integer
Dim jj As Long
Dim Cu1$, Cu2$, Cu3$, Cu4$, Cu5$, Cu6$, cu7$, Cu8$, Cu9$, Cu10$, Cu11$, Cu12$, Cu13$
Cu1 = ""
Cu2 = ""
Cu3 = ""
Cu4 = ""
Cu5 = ""
Cu6 = ""
cu7 = ""
Cu8 = ""
Cu9 = ""
Cu10 = ""
Cu11 = ""
Cu12 = ""
Cu13 = ""
jj = 0
ListBox1.Clear
ListBox1.ColumnCount = 15 'nb de colonne
ListBox1.ColumnWidths = "50;30;80;15;90;60;30;15;15;10"
ListBox1.FontSize = 10
'ListBox1.ColumnHeads = True
ListBox1.BackColor = &HFFFF80 'font de la liste boxe
ListBox1.TextAlign = fmTextAlignCenter
derniereligne = Sheets("feuil2").Range("A4").End(xlDown).Row 'derniere ligne occupee dans colonne A
For lignedebut = 4 To derniereligne 'on test le contenu des combobox
If ComboBox24.Value <> "" Then Cu1 = ComboBox24.Value Else Cu1 = Sheets("feuil2").Cells(lignedebut, 2)
If ComboBox6.Value <> "" Then Cu2 = ComboBox6.Value Else Cu2 = Sheets("feuil2").Cells(lignedebut, 1)
If ComboBox5.Value <> "" Then Cu3 = ComboBox5.Value Else Cu3 = Sheets("feuil2").Cells(lignedebut, 4)
If ComboBox26.Value <> "" Then Cu4 = ComboBox26.Value Else Cu4 = Sheets("feuil2").Cells(lignedebut, 3)
If ComboBox14.Value <> "" Then Cu5 = ComboBox14.Value Else Cu5 = Sheets("feuil2").Cells(lignedebut, 20)
If ComboBox15.Value <> "" Then Cu6 = ComboBox15.Value Else Cu6 = Sheets("feuil2").Cells(lignedebut, 21)
If ComboBox16.Value <> "" Then cu7 = ComboBox16.Value Else cu7 = Sheets("feuil2").Cells(lignedebut, 22)
If ComboBox17.Value <> "" Then Cu8 = ComboBox17.Value Else Cu8 = Sheets("feuil2").Cells(lignedebut, 19)
If ComboBox23.Value <> "" Then Cu9 = ComboBox23.Value Else Cu9 = Sheets("feuil2").Cells(lignedebut, 9)
If ComboBox22.Value <> "" Then Cu10 = ComboBox22.Value Else Cu10 = Sheets("feuil2").Cells(lignedebut, 11)
If ComboBox19.Value <> "" Then Cu11 = ComboBox19.Value Else Cu11 = Sheets("feuil2").Cells(lignedebut, 10)
If ComboBox9.Value <> "" Then Cu12 = ComboBox9.Value Else Cu12 = Sheets("feuil2").Cells(lignedebut, 16)
If ComboBox8.Value <> "" Then Cu13 = ComboBox8.Value Else Cu13 = Sheets("feuil2").Cells(lignedebut, 17)
'test final avec toute les conditon imbriquee
'affichage dans listbox en multicolonne
If Sheets("feuil2").Cells(lignedebut, 2) = Cu1 And Sheets("feuil2").Cells(lignedebut, 1) = Cu2 And Sheets("feuil2").Cells(lignedebut, 4) = Cu3 And Sheets("feuil2").Cells(lignedebut, 3) = Cu4 And Sheets("feuil2").Cells(lignedebut, 20) = Cu5 And Sheets("feuil2").Cells(lignedebut, 21) = Cu6 And Sheets("feuil2").Cells(lignedebut, 22) = cu7 And Sheets("feuil2").Cells(lignedebut, 19) = Cu8 Then
'And Sheets("feuil2").Cells(lignedebut, 20) = Cu5 And Sheets("feuil2").Cells(lignedebut, 21) = Cu6 And Sheets("feuil2").Cells(lignedebut, 22) = Cu7 And Sheets("feuil2").Cells(lignedebut, 19) = Cu8
ListBox1.AddItem
ListBox1.Column(0, jj) = Sheets("feuil2").Cells(lignedebut, 2).Value
ListBox1.Column(1, jj) = Sheets("feuil2").Cells(lignedebut, 1).Value
ListBox1.Column(2, jj) = Sheets("feuil2").Cells(lignedebut, 4).Value
ListBox1.Column(3, jj) = Sheets("feuil2").Cells(lignedebut, 3).Value
ListBox1.Column(4, jj) = Sheets("feuil2").Cells(lignedebut, 20).Value
ListBox1.Column(5, jj) = Sheets("feuil2").Cells(lignedebut, 21).Value
ListBox1.Column(6, jj) = Sheets("feuil2").Cells(lignedebut, 22).Value
ListBox1.Column(7, jj) = Sheets("feuil2").Cells(lignedebut, 19).Value
ListBox1.Column(8, jj) = Sheets("feuil2").Cells(lignedebut, 9).Value
ListBox1.Column(9, jj) = Sheets("feuil2").Cells(lignedebut, 11).Value
ICI 'ListBox1.Column(10, jj) = Sheets("feuil2").Cells(lignedebut, 10).Value
'ListBox1.Column(11, jj) = Sheets("feuil2").Cells(lignedebut, 16).Value
'ListBox1.Column(12, jj) = Sheets("feuil2").Cells(lignedebut, 17).Value
'ListBox1.Column(13, jj) = lignedebut '(il faut masque cette ligne en mettant o dans la larguer de la colonne)
jj = jj + 1
End If
Next lignedebut
End Sub |
Partager