Pb de recherche VLOCKUP en VBA

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

Bonjour

SVP. je dois organiser ma compet ce week-end

personne pour me donner un coup de main ?

Merci


Bonjour

SVP. je dois organiser ma compet ce week-end

personne pour me donner un coup de main ?

Merci

Bonjour,

Essaie comme cela

Private Sub ListBox2_Click()
Dim f As Worksheet
Dim a
Dim j As Integer, i As Integer
Dim rech As String
Dim res 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 res = Worksheets("TABLEAU").Columns(3).Find(rech, , xlValues, xlWhole)
            If Not res Is Nothing 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

A+

Bonjour et bienvenue sur le forum

Bonjour Frangy

Une variante :

Bye !

Merci Beaucoup

cela fonctionne

Rechercher des sujets similaires à "recherche vlockup vba"