Bonsoir
Je suis nouveau sur ce forum qui a l'air très complet.
j'ai un soucis dans mon code VBA. L'objectif est de mettre dans une listbox qui se trouve dans la feuile TABLEAU les joueurs inscrits ( Feuille INSCRIT) qui ne se trouvent pas dans le tableau (Feuille TABLEAU) . la recherche se fait sur le numéro de licence
il ne trouve jamais le joueur dans le tableau donc tous les inscrits sont ajoutés dans la LISTBOX
Voici mon code pour alimenter la listbox
Dim rech As String
Dim res As Variant
Dim MaPlageRecherche As Range
Dim Lookup_range As Range
Set f = Sheets("INSCRITS")
Me.ListBox2.Clear
a = f.Range("a2:g2" & f.[A5000].End(xlUp).Row)
j = 0
ListBox2.ColumnCount = 5
ListBox2.ColumnWidths = "55;100;60;100;30"
For i = LBound(a) To UBound(a)
If a(i, 1) <> "" Then
rech = a(i, 1)
Set Lookup_range = Worksheets("TABLEAU").Columns("A:I")
res = Application.VLookup(rech, Lookup_range, 5, 0)
If IsError(res) Then
Me.ListBox2.AddItem a(i, 1)
Me.ListBox2.List(j, 1) = a(i, 2)
Me.ListBox2.List(j, 2) = a(i, 3)
Me.ListBox2.List(j, 3) = a(i, 4)
Me.ListBox2.List(j, 4) = a(i, 5)
Me.ListBox2.List(j, 4) = a(i, 7)
j = j + 1
End If
End If
Next i
End Sub
SI vous avez une idée . je vous joins le fichier
Merci par avance pour votre aide