Macro "Recherche une Valeur" dans un Userform
Bonjour,
j'aurai besoin d'un peu d'aide pour une macro que j'ai dans un userform.
Le but est simplement de rechercher dans une colonne (colonne B) une valeur rentrée dans un userform.
La macro ne trouve pas la valeur (et me renvoie un msgbox "book non trouvé" alors qu'elle s'y trouve bien.
voici mon code:
Merci beaucoup pour votre aide!!
Code:
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
| Dim repere As Boolean
Dim trouve As Boolean
Set OngletLiffe = ThisWorkbook.Worksheets("Liffe")
repere = False
trouve = False
If (UserForm1.CbookFO = "") Then
VbookFO = ""
Else
VbookFO = UserForm1.CbookFO
End If
If (VbookFO <> "") Then 'vérifie que le champ de l'userform n'est pas vide
If (Not IsNumeric(VbookFO)) Then 'vérifie que le champ n'est pas numérique
ligne = 1
Do While (repere = False) 'boucle recherchant la valeur
ligne = ligne + 1
If OngletLiffe.Cells(ligne, 2).Text = "" Then
repere = True
End If
If OngletLiffe.Cells(ligne, 2).Text = Val(VbookFO) Then
repere = True
trouve = True
End If
Loop
If (trouve = True) Then
UserForm1.CbookBP2S = OngletLiffe.Cells(ligne, 1)
UserForm1.CbookFO = OngletLiffe.Cells(ligne, 2)
UserForm1.Ctrader = OngletLiffe.Cells(ligne, 3)
UserForm1.Cmiddle = OngletLiffe.Cells(ligne, 4)
Else
MsgBox ("Book non trouvé!")
End If
Else
MsgBox ("Veuillez saisir un book valide")
End If
Else
MsgBox ("Veuillez choisir un book à rechercher SVP")
End If |