bonjour,
j,ai récupéré une portion de code chez notre ami Monsieur Boisgonthier qui me permet de chercher un nom dans notre base de donnée. par contre lorsqu'il ne le trouve pas j'obtient un erreur. Comment puis-je inscrire dans le code que si rien de correspond d'indiquer une message et de rien faire.
code:
Private Sub B_ok_Click()
Me.ListBox1.Clear
i = 0
Set plage = f.[A1].CurrentRegion
Set c = plage.Find(Me.MotCle, , , xlPart)
If Not c Is Nothing Then
premier = c.Address
Do
Me.ListBox1.AddItem
lig = c.Row
Me.ListBox1.List(i, 0) = plage.Cells(lig, 1)
Me.ListBox1.List(i, 1) = lig
i = i + 1
Set c = plage.FindNext(c)
Loop While Not c Is Nothing And c.Address <> premier
End If
pointeur = 0
ligne = Me.ListBox1.List(pointeur, 1)
affiche
End Sub
Private Sub b_tout_Click()
Me.ListBox1.Clear
For i = 2 To f.[A65000].End(xlUp).Row
Me.ListBox1.AddItem
Me.ListBox1.List(i - 2, 0) = f.Cells(i, 1)
Me.ListBox1.List(i - 2, 1) = i
Next
pointeur = 0
ligne = Me.ListBox1.List(pointeur, 1)
affiche
End Sub
j,ai récupéré une portion de code chez notre ami Monsieur Boisgonthier qui me permet de chercher un nom dans notre base de donnée. par contre lorsqu'il ne le trouve pas j'obtient un erreur. Comment puis-je inscrire dans le code que si rien de correspond d'indiquer une message et de rien faire.
code:
Private Sub B_ok_Click()
Me.ListBox1.Clear
i = 0
Set plage = f.[A1].CurrentRegion
Set c = plage.Find(Me.MotCle, , , xlPart)
If Not c Is Nothing Then
premier = c.Address
Do
Me.ListBox1.AddItem
lig = c.Row
Me.ListBox1.List(i, 0) = plage.Cells(lig, 1)
Me.ListBox1.List(i, 1) = lig
i = i + 1
Set c = plage.FindNext(c)
Loop While Not c Is Nothing And c.Address <> premier
End If
pointeur = 0
ligne = Me.ListBox1.List(pointeur, 1)
affiche
End Sub
Private Sub b_tout_Click()
Me.ListBox1.Clear
For i = 2 To f.[A65000].End(xlUp).Row
Me.ListBox1.AddItem
Me.ListBox1.List(i - 2, 0) = f.Cells(i, 1)
Me.ListBox1.List(i - 2, 1) = i
Next
pointeur = 0
ligne = Me.ListBox1.List(pointeur, 1)
affiche
End Sub