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
| Sub Tri()
Dim ShSource As Worksheet
Dim ShCible As Worksheet
Dim i As Long
Dim iCible As Long
Dim Col As Integer
Dim Rg As Range
Set ShSource = ThisWorkbook.Sheets("Feuil1")
Set ShCible = ThisWorkbook.Sheets("Feuil2")
For i = 5 To ShSource.Range("A" & Rows.Count).End(xlUp).Row
iCible = ShCible.Range("A" & Rows.Count).End(xlUp).Row + 1
ShCible.Range("A" & iCible).Value = ShSource.Range("A" & i).Value
For Col = 2 To 11 Step 2 'traitement des colonnes
'Cherche la colonne cible
Set Rg = ShCible.Range("A1:L1").Find(what:=ShSource.Cells(i, Col).Value, lookat:=xlWhole)
'Traitement si trouvé
If Not Rg Is Nothing Then
ShCible.Cells(iCible, Rg.Column).Value = ShSource.Cells(i, Col + 1).Value
End If
Next Col
Next i
End Sub |