Remplacer les données d’une colonne de maniére dynamique par

Bonjour le forum,

J’aimerai avoir un code vba qui me permettrai de remplacer les données d’une colonne de maniére dynamique par celles d’un tableau de correspondance.

Ci-dessous un exemple .

Merci.

TABLEAU ORIGINE

[table="width: 500, class: grid"]

NOM

TABLEAU DE CORRESPONDANT

[table="width: 500, class: grid"]

PAYS

RESULTAT ATTENDU

[table="width: 500, class: grid"]

NOM

11classeur1.xlsx (10.37 Ko)

Bonjour,

Une proposition à tester.

Cdlt.

Bonjour JEAN ERIC,

j'ai essayé mais j'au une erreur de compilation.

erreur2

Re,

Je n'ai pas vérifié le résultat si aucune correspondance.

Je reverrai la chose cet après-midi.

Cdlt.


Re,

Pourquoi reporter?

Cdlt.

Option Explicit

Private Sub cmdCodeOTAN_Click()
Dim ws, ws2 As Worksheet
Dim objList As ListObject, objList2 As ListObject
Dim Cell As Range
Dim Result As Variant

    Application.ScreenUpdating = False

    Set ws = Worksheets("Données"): Set ws2 = Worksheets("Liste")
    Set objList = ws.ListObjects(1): Set objList2 = ws2.ListObjects(1)

    With ws
        For Each Cell In objList.ListColumns(4).DataBodyRange
            Result = Application.VLookup(Cell.Value, objList2.DataBodyRange, 2, False)
            If IsError(Result) Then
                Cell.Value = "N/A"
            Else
                Cell.Value = Result
            End If
        Next Cell
    End With

    Set objList = Nothing: Set objList2 = Nothing
    Set ws2 = Nothing: Set ws = Nothing

End Sub

merci JEAN ERIC,

ça marche

Re,

Pas de quoi Atitila.

Rechercher des sujets similaires à "remplacer donnees colonne maniere dynamique"