J'ai cette procédure VBA ci-dessous qui me permet de compléter ma
feuille Datas en me basant sur un code se trouvant sur mes deux feuilles
en A.
Mais mon problème est qu'il peut y avoir des doublons dans ma feuille
NumeroID.
Donc j'aimerais adapter cette procédure pour que celle-ci se base sur
la Colonne A et B de chaque feuille.
En A sur ma feuille "NumeroID", j'ai un code qui malheureusement n'est
pas toujours unique et en B j'ai le nom des personnes.
En me basant sur ces deux cellules, je ne devrait plus avoir ce problème.
Une Idée ?
Déjà merci
Sub RechercheNumero()
Dim Nom As String, i As Long, j As Long
Sheets("Datas").Select
i = 3
With Sheets("NumeroID")
Do While Cells(i, 1) <> ""
Nom = Cells(i, 1)
For j = 1 To .Range("A65536").End(xlUp).Row
If Nom = .Cells(j, 1) Then
Cells(i, 3) = .Cells(j, 3)
Cells(i, 4) = .Cells(j, 4)
Cells(i, 12) = .Cells(j, 7)
Exit For
End If
Next
i = i + 1
Loop
End With
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
h2so4
bonsoir,
If used his keyboard to write : Sub RechercheNumero() Dim Nom As String, i As Long, j As Long Sheets("Datas").Select i = 3 derlig = .Range("A65536").End(xlUp).Row With Sheets("NumeroID") Do While Cells(i, 1) <> "" NomA = Cells(i, 1) NomB = cells(i,2) For j = 1 To derlig If NomA = .Cells(j, 1) and NomB = .cells(j,2)Then Cells(i, 3) = .Cells(j, 3) Cells(i, 4) = .Cells(j, 4) Cells(i, 12) = .Cells(j, 7) Exit For End If Next i = i + 1 Loop End With End Sub
-- h2so4 ca PAN pique DORA .
bonsoir,
If used his keyboard to write :
Sub RechercheNumero()
Dim Nom As String, i As Long, j As Long
Sheets("Datas").Select
i = 3
derlig = .Range("A65536").End(xlUp).Row
With Sheets("NumeroID")
Do While Cells(i, 1) <> ""
NomA = Cells(i, 1)
NomB = cells(i,2)
For j = 1 To derlig
If NomA = .Cells(j, 1) and NomB = .cells(j,2)Then
Cells(i, 3) = .Cells(j, 3)
Cells(i, 4) = .Cells(j, 4)
Cells(i, 12) = .Cells(j, 7)
Exit For
End If
Next
i = i + 1
Loop
End With
End Sub
If used his keyboard to write : Sub RechercheNumero() Dim Nom As String, i As Long, j As Long Sheets("Datas").Select i = 3 derlig = .Range("A65536").End(xlUp).Row With Sheets("NumeroID") Do While Cells(i, 1) <> "" NomA = Cells(i, 1) NomB = cells(i,2) For j = 1 To derlig If NomA = .Cells(j, 1) and NomB = .cells(j,2)Then Cells(i, 3) = .Cells(j, 3) Cells(i, 4) = .Cells(j, 4) Cells(i, 12) = .Cells(j, 7) Exit For End If Next i = i + 1 Loop End With End Sub