Sub traite()
Dim Chrono As Double, chrono2 As Double
Dim Inventaire As Variant, Modele As Variant
Dim Reference As Variant
Dim MaxModele As Long, Nblignes As Long
Dim Pointeur As Long, GroupeCol As Long, Actuel As Long
Dim Trouve As Range
Dim Groupe As String
Chrono = Timer
Application.ScreenUpdating = False
Sheets("Résultat").Range("A2:E" & Sheets("Résultat").Range("A" & Rows.Count).End(xlUp).Row).ClearContents
Inventaire = Sheets("A Traiter").Range("A2:E" & Sheets("A Traiter").Range("A" & Rows.Count).End(xlUp).Row)
Nblignes = 2
For Pointeur = 2 To UBound(Inventaire, 1)
If Inventaire(Pointeur, 2) <> Groupe Then
Set Trouve = Sheets("Groupe").Range("A1:BA1").Find(Inventaire(Pointeur, 2), lookat:=xlValue)
If Not Trouve Is Nothing Then
Groupe = Trouve.Text
GroupeCol = Trouve.Column
MaxModele = Sheets("Groupe").Cells(Rows.Count, GroupeCol).End(xlUp).Row
Modele = Sheets("Groupe").Range("A2:A" & MaxModele).Offset(0, GroupeCol - 1)
Else
MsgBox "Marque non trouvée"
Exit Sub
End If
End If
For Actuel = 1 To MaxModele - 1
Reference = Array(Inventaire(Pointeur, 1), Inventaire(Pointeur, 2), Modele(Actuel, 1), Inventaire(Pointeur, 4), Inventaire(Pointeur, 5))
Sheets("résultat").Range("A" & Nblignes & ":E" & Nblignes) = Reference
Nblignes = Nblignes + 1
Next Actuel
Next Pointeur
Application.ScreenUpdating = True
chrono2 = Timer - Chrono
End Sub