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
| Sub comparer()
Dim ChCel As Range, Plage1 As Range, Plage2 As Range, tBl1(), tBl2()
Dim x As Long, y As Long, dl As Long, chaineTbl As String, chaineCel As String
With Sheets("feuil1")
dl = .Range("A" & .Rows.Count).End(xlUp).Row 'derniere ligne renseignée
ReDim tBl1(1 To dl, 1 To 8)
Set Plage1 = .Range("A2:H" & dl)
tBl1() = Plage1
End With
With Sheets("feuil2")
dl = .Range("A" & .Rows.Count).End(xlUp).Row 'derniere ligne renseignée
ReDim tBl2(1 To dl, 1 To 8)
Set Plage2 = .Range("A2:H" & dl)
tBl2() = Plage2
For x = 1 To UBound(tBl1, 1)
Set ChCel = Plage2.Find(tBl1(x, 1))
If ChCel Is Nothing Then
Sheets("feuil1").Range("B" & x + 1) = "Nouveau"
Else
chaineTbl = tBl1(x, 3) & tBl1(x, 4) & tBl1(x, 5) & tBl1(x, 6) & tBl1(x, 7) & tBl1(x, 8)
chaineCel = .Range("C" & ChCel.Row) & .Range("D" & ChCel.Row) & .Range("E" & ChCel.Row) & .Range("F" & ChCel.Row) & .Range("G" & ChCel.Row) & .Range("H" & ChCel.Row)
If chaineTbl = chaineCel Then Sheets("feuil1").Range("B" & x + 1) = "Présent"
If chaineTbl <> chaineCel Then Sheets("feuil1").Range("B" & x + 1) = "Modifié"
End If
Next x
End With
End Sub |
Partager