Problème avec .find et findnext
*Bonjour*
J'ai un problème... ont m'a demandé de trier à l'aide d'une useform plus de 4500 numéro de produit avec leurs définition... je me suis débrouillé pour donner à mon patron ce qu'il désire. Cependant j'ai fait deux procédure afin de : pouvoir calculer le nombre de produit à trier (sur 3 feuille dans le même classeur). C'est à dire que j'ai créer un tableau tableau(4700) et ainsi je peux à l'aide d'un compteur savoir le nombre d'item que je dois inséré dans ma listebox dans ma prochaine procédure avec Redim. Tout marche à merveil lorsque je lance l'application pour la première fois... le problème est lorsque je sélectionne mon produit dans ma listbox afin de voir toute les informations qui s'y rattache, je ne suis plus capable de rentrer dans mes tableaux... .find et findnext ne fonctionne plus et je dois fermer mon classeur afin de pouvoir lancer une nouvelle recherche
*Merci*
Voici une partie du code de recherche produit, il envoi des données dans un liste box
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| Private Sub Recherche_Prod()
Dim Resultat_Trouve As Range
Dim Ligne_Produit() As Variant
Dim Grandeur_Prod() As Variant
Dim I As Integer, Ligne_Resulta As Integer
Dim Grandeur As String
Dim Recherche_Donnes As String
Dim FirstAddress As String
Dim a As Integer
Dim CellStart As String
Dim DDD As Object
I = 0
ReDim Ligne_Produit(Cmpt_Tb_prod)
ReDim Grandeur_Prod(Cmpt_Tb_Size)
FirstAddress = ""
Recherche_Donnes = No_Prod
ListBox1.ColumnCount = Cmpt_Tb_prod
Worksheets(1).Activate
Range("A1").Select
With Worksheets(1).Range("a17:a2300")
Set Resultat_Trouve = .Find(Recherche_Donnes, LookIn:=xlValues)
If Not Resultat_Trouve Is Nothing Then
FirstAddress = Resultat_Trouve.Address
a = 0
Do
If Len(Resultat_Trouve) < 6 Then
Set Resultat_Trouve = .FindNext(Resultat_Trouve)
Else
If Len(Resultat_Trouve) = 22 Then
Grandeur = Mid(Resultat_Trouve, 7, 4)
ElseIf Len(Resultat_Trouve) = 23 Then
Grandeur = Mid(Resultat_Trouve, 8, 4)
ElseIf Len(Resultat_Trouve) = 24 Then
Grandeur = Mid(Resultat_Trouve, 7, 6)
End If
If I = 0 Then
Grandeur_Prod(a) = Grandeur
a = a + 1
Else
If Len(Grandeur) >= 2 Then
If Grandeur <> Grandeur_Prod(a - 1) Then
Grandeur_Prod(a) = Grandeur
a = a + 1
End If
End If
End If
Ligne_Produit(I) = Resultat_Trouve
Set Resultat_Trouve = .FindNext(Resultat_Trouve)
I = I + 1
End If
Loop While Not Resultat_Trouve Is Nothing And Resultat_Trouve.Address <> FirstAddress
End If
End With
Worksheets(2).Activate
Range("A1").Select
With Worksheets(2).Range("a17:a2300")
Set Resultat_Trouve = .Find(Recherche_Donnes, LookIn:=xlValues)
If Not Resultat_Trouve Is Nothing Then
FirstAddress = Resultat_Trouve.Address
Do
If Len(Resultat_Trouve) < 6 Then
Set Resultat_Trouve = .FindNext(Resultat_Trouve)
Else
Ligne_Produit(I) = Resultat_Trouve
Set Resultat_Trouve = .FindNext(Resultat_Trouve)
I = I + 1
End If
Loop While Not Resultat_Trouve Is Nothing And Resultat_Trouve.Address <> FirstAddress
End If
End With
Worksheets(3).Activate
Range("A1").Select
With Worksheets(3).Range("a17:a1800")
Set Resultat_Trouve = .Find(Recherche_Donnes, LookIn:=xlValues)
If Not Resultat_Trouve Is Nothing Then
FirstAddress = Resultat_Trouve.Address
Do
If Len(Resultat_Trouve) < 6 Then
Set Resultat_Trouve = .FindNext(Resultat_Trouve)
Else
Ligne_Produit(I) = Resultat_Trouve
Set Resultat_Trouve = .FindNext(Resultat_Trouve)
I = I + 1
End If
Loop While Not Resultat_Trouve Is Nothing And Resultat_Trouve.Address <> FirstAddress
End If
End With
ComboBox2.List = Grandeur_Prod()
Dim Entrer_L_Box As Single
Entrer_L_Box = Entrer_L_Box = 1
No_Produit = Ligne_Produit(I)
If Check_Clic < 1 Then
ListBox1.List = Ligne_Produit()
End If
Dim dan As Integer
dan = ListBox1.ColumnCount
If dan = 1 Then
ListBox1.ListIndex = -1
Var_2 = ListBox1.Text
Call Rec_Pro_Specifique
End If
End Sub |
Comme je l'ai expliquer précédament la procédure fonctionne la première fois, cependant lorsque je sélecitonne un produit par la suite ma variable resultat_trouvé (range) ne garde que les 4 première lettre du code de produit passé par No_prod... si vous avez besoin de plus d'info je vais vous les communiquer avec plaisir mais je ne savais pas si je pouvais mettre plus de code dans cette fenêtre.
Merci