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
|
Private Sub recherche() 'recherche multicritere
Dim lignedebut As Integer
Dim derniereligne As Integer
Dim c1$, c2$, c3$, c4$, c5$, c6$, j
Dim Cu1$, Cu2$, Cu3$, Cu4$, Cu5$, Cu6$
Cu1 = "" 'type installation
Cu2 = "" 'n° installation
Cu3 = "" 'site
Cu4 = "" 'entreprise
Cu5 = "" 'etablissement
j = 0
ListBox1.Clear
ListBox1.BoundColumn = 5
ListBox1.ColumnWidths = "15;15;20;10;10;"
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 ComboBox5.Value <> "" Then Cu3 = ComboBox5.Value Else Cu3 = Sheets("feuil2").Cells(lignedebut, 6)
If ComboBox6.Value <> "" Then Cu2 = ComboBox6.Value Else Cu2 = Sheets("feuil2").Cells(lignedebut, 1)
If ComboBox22.Value <> "" Then Cu4 = ComboBox22.Value Else Cu4 = Sheets("feuil2").Cells(lignedebut, 11)
If ComboBox24.Value <> "" Then Cu1 = ComboBox24.Value Else Cu1 = Sheets("feuil2").Cells(lignedebut, 2)
If ComboBox3.Value <> "" Then Cu5 = ComboBox3.Value Else Cu5 = Sheets("feuil2").Cells(lignedebut, 7)
'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, 6) = Cu3 And Sheets("feuil2").Cells(lignedebut, 11) = Cu4 Then
ListBox1.AddItem
ListBox1.Column(0, j) = Sheets("feuil2").Cells(lignedebut, 1).Value 'n°installation
ListBox1.Column(1, j) = Sheets("feuil2").Cells(lignedebut, 2).Value 'type installation
ListBox1.Column(2, j) = Sheets("feuil2").Cells(lignedebut, 6).Value 'site
ListBox1.Column(3, j) = Sheets("feuil2").Cells(lignedebut, 7).Value 'etablissement
ListBox1.Column(4, j) = Sheets("feuil2").Cells(lignedebut, 11).Value 'entreprise
j = j + 1
End If
Next lignedebut
End Sub |