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
| Private Sub Lancer_Click()
Dim i As Integer, ColR As Byte, ColV As Byte
Dim Colect As New Collection, Result As Boolean
Result = False
If Me.TextBox1.Value = "" Then
MsgBox "Veuillez préciser la donnée à rechercher", vbExclamation
Exit Sub
End If
If Me.ComboBox1.Value = "" Then
MsgBox "Veuillez sélectionner le type de recherche", vbExclamation
Exit Sub
End If
Select Case Me.ComboBox1.Value
Case "P.C.F"
ColR = 3
ColV = 2
Case "Schémas 9S"
ColR = 2
ColV = 3
End Select
With Sheets("Feuil4")
For i = 2 To .Cells(Rows.Count, ColR).End(xlUp).Row
If .Cells(i, ColR).Text = Me.TextBox1 Then
Result = True
Colect.Add .Cells(i, ColV).Text, CStr(.Cells(i, ColV))
End If
Next i
End With
If Result = True Then
Me.TextBox2 = "EXISTANT"
For i = 1 To Colect.Count
Me.ListBox1.AddItem Colect.Item(i)
Next
Else
Me.TextBox2 = "INEXISTANT"
End If
End Sub |