[Excel/VBA] Erreur dans un programme

Fermé
bb - 22 juil. 2005 à 04:24
 bb - 22 juil. 2005 à 05:30
Bonjour a tous
Alors voila c'est tous simple, j'ai fait un programme qui semble fonctionner mais qui s'arrete un endroit et toujours au meme!
Je m'explique ce programme a pour but de chercher dans 3 tableau excel des une reference de produit et une 2eme reference.
Dans tous les tableaux il y a ces 2 donnees.
Ensuite je les fais afficher dans une listbox, mais le programme s'arrete toujours au meme ligne.
Voici le code.Je precise juste que le programme doit en tout chercher dans pres de 20 000 lignes!
Merci d'avance pour toute aide
Bruno


Private Sub CommandButton2_Click()
m = 2
l = 2
b = 2
i = 1
Dim ItemnoT1 As String
Dim ItemnoT2 As String
Dim LocatT1 As String
Dim LocatT2 As String
Dim Utilise As Single
Dim List_2(2 To 600, 1 To 7) As String


For l = 2 To 3600

If Worksheets("ABC analysis page").Cells(l, 1).Value <> "" Or Worksheets("ABC analysis page").Cells(l, 2).Value <> "" Then
For m = 2 To 550 'search every same product on the 2 table in the "Main Page"
ItemnoT2 = Worksheets("Main Page").Cells(m, 38).Value
LocatT2 = Worksheets("Main Page").Cells(m, 39).Value
ItemnoT1 = Worksheets("ABC analysis page").Cells(l, 1).Value
LocatT1 = Worksheets("ABC analysis page").Cells(l, 2).Value

If ItemnoT2 = ItemnoT1 And LocatT2 = LocatT1 Then
Utilise = 1
On Error GoTo erreur
Cells.Find (ItemnoT2)
If Utilise = 1 Then
Refadress1 = 0
Refadress2 = 0
Worksheets("sheet3").Activate
Cells.Find(ItemnoT2).Activate
Refadress1 = ActiveCell.Address(ReferenceStyle:=xlA1)
Range(Refadress1).Select
ActiveCell.Offset(0, -1).Activate
Refadress2 = ActiveCell.Address(ReferenceStyle:=xlA1)

While (Range(Refadress1).Value <> ItemnoT2 Or Range(Refadress2).Value <> LocatT2) And i < 9
ActiveCell.Offset(1, 0).Activate
Refadress1 = ActiveCell.Address(ReferenceStyle:=xlA1)
Range(Refadress2).Select
ActiveCell.Offset(1, 0).Activate
Refadress2 = ActiveCell.Address(ReferenceStyle:=xlA1)
i = i + 1
Wend


If i <> 9 And b < 600 Then 'search wich product found before present in the table in "sheet3"

List_2(b, 1) = Worksheets("Main Page").Cells(m, 38).Value 'ref product
List_2(b, 2) = Worksheets("Main Page").Cells(m, 39).Value 'location


[...]

b = b + 1
UserForm2.ListBox1.list = List_2
End If
End If
End If
Next m
End If
Next l




erreur:
If Err.Number = 91 Then
Utilise = 0
End If
End Sub

Merci d'avance pour toute reponse
A voir également:

1 réponse

resalut
J'ai juste oublier une ligne<:P
avant ce passage, j'ai une ligne en plus

While (Range(Refadress1).Value <> ItemnoT2 Or Range(Refadress2).Value <> LocatT2) And i < 9
ActiveCell.Offset(1, 0).Activate
Refadress1 = ActiveCell.Address(ReferenceStyle:=xlA1)
Range(Refadress2).Select
ActiveCell.Offset(1, 0).Activate
Refadress2 = ActiveCell.Address(ReferenceStyle:=xlA1)
i = i + 1
Wend


i=1

Merci d'avance pour toute aide
Bruno
0