1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Dim fl1 As Worksheet
Private Sub Recherche_Click()
Dim MotCherche, plage As range, Cell As range, range As range
MotCherche = Me.TextBo1.Text
colonnerecherche = range(1)
'On lance la recherche sur la colonne ColonneRecherche
Set plage = fl1.range(Cells(1, colonnerecherche), _
Cells(range("A65536").End(xlUp).Row, colonnerecherche))
With plage
Set c = .Find(MotCherche, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then 'donnée trouvée
'On place les données de la ligne dans les textbox
Me.TextBox2.Text = fl1.Cells(c.Row, 2).Value
Else
MsgBox "Donnée non trouvée"
End If
End With
MotCherche = Me.TextBo1.Text
If MotCherche = "" Then
MsgBox "Tapez au moins les deux premiers chiffre !", _
vbCritical, "Manque valeur de recherche"
End If
End Sub |
Partager