Sub ChoixAF1()
Dim AFclient As String
Dim AFexercice As String
Dim AFcategorie As String
Dim AFdonnees As Variant
Dim Item As Integer
Dim Col As Byte
Dim AFclientCompare As String
Dim AFexerciceCompare As String
Dim AFcategorieCompare As String
Dim ligneReport As Integer
Application.ScreenUpdating = False
With Worksheets("AF") 'avec la feuille "AF"
AFclient = .Range("K2") 'on affecte les valeur aux variables
AFexercice = .Range("L2")
AFcategorie = .Range("M2")
AFdonnees = .Range("B8:I" & .Range("B1048576").End(xlUp).Row) 'on remplit un tableau
.Range("K8:R" & .Range("K1048576").End(xlUp).Row + 1).ClearContents 'on efface les données
For Item = 1 To UBound(AFdonnees, 1) 'pour chaque ligne de ce tableau
AFclientCompare = AFdonnees(Item, 1) 'on récupére les valeurs à comparer
AFexerciceCompare = AFdonnees(Item, 2)
AFcategorieCompare = AFdonnees(Item, 3)
If AFclientCompare = AFclient And AFexerciceCompare = AFexercice And AFcategorieCompare = AFcategorie Then 'si egalité
ligneReport = .Range("K1048576").End(xlUp).Row + 1 'on détecte la derniere ligne vide de la colonne K
For Col = 1 To UBound(AFdonnees, 2) 'pour chaque colonne du tableau
.Cells(ligneReport, Col + 10) = AFdonnees(Item, Col) 'sinon on colle telquel
Next Col
End If
Next Item
End With
Application.ScreenUpdating = True
End Sub