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 33 34 35 36 37 38 39 40 41
| Sub comparer()
Dim l, ll As Integer 'ligne colonne 1 et 5'
Dim nbl, nbll As Integer
Dim sup As Integer
'nombre de lignes'
nbl = Application.CountA(Columns(1)) ' si lignes vide en en tete, ajouter "+ ...'
nbll = Application.CountA(Columns(5))
nbc = Application.CountA(Rows(5)) + 1
For l = 3 To nbl 'recopier les lignes du premier tableau'
Cells(l, 10) = Cells(l, 1)
Cells(l, 11) = Cells(l, 2)
Cells(l, 12) = Cells(l, 3)
Cells(l, 13) = Cells(l, 4)
For ll = 3 To nbll 'chercher la ligne correspondante dans second tableau et recopier'
If Cells(l, 1) = Cells(ll, 5) Then
Cells(l, 14) = Cells(ll, 5)
Cells(l, 15) = Cells(ll, 6)
Cells(l, 16) = Cells(ll, 7)
Cells(l, 17) = Cells(ll, 8)
Cells(ll, 9) = "x"
End If
Next
Next
sup = 1
For l = 3 To nbll 'ajouter les lignes nouvelles'
If Cells(l, 9) <> "x" Then
Cells(nbl + sup, 14) = Cells(l, 5)
Cells(nbl + sup, 15) = Cells(l, 6)
Cells(nbl + sup, 16) = Cells(l, 7)
Cells(nbl + sup, 17) = Cells(l, 8)
sup = sup + 1
End If
Next
End Sub |
Partager