1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Sub transvalue()
Dim enTete, cellSource, cellCible, searchRange As Range
Dim LigneHaut, LigneBas, ColHaut, ColBas As Integer
Dim LHautSearch, LBAsSearch, CHautSearch, CBasSearch As Integer
LigneHaut = Selection.Row
LigneBas = Selection.Rows.Count + Selection.Row - 1
ColHaut = Selection.Column
ColBas = Selection.Columns.Count + Selection.Column - 1
'SOurce du Recherchev à éditer si ajouter de nouvelles valeurs
Set searchRange = ThisWorkbook.Worksheets("Key").Range("B2:C3")
For numCol = ColHaut To ColBas
Set enTete = Cells(1, numCol)
For numLigne = (LigneHaut + 1) To LigneBas
Set cellSource = Cells(numLigne, numCol)
searchKey = enTete.Value & cellSource.Value
With ThisWorkbook.Worksheets("Cible")
Set cellCible = .Range(.Cells(numLigne, numCol), .Cells(numLigne, numCol))
End With
cellCible.Value = WorksheetFunction.VLookup(searchKey, searchRange, 3, False)
Next numLigne
Next numCol
End Sub |
Partager