[COLOR="DarkSlateGray"][B]Sub toto()
Dim i&, j&, tmp, ComNL, ComPrevNL, CollPrevNL As New Collection
With Sheets("NL")
ComNL = .Range(.Cells(1, 3), .Cells(.Rows.Count, 3).End(xlUp)).Value
End With
With Sheets("PrevNL")
ComPrevNL = .Range(.Cells(1, 3), .Cells(.Rows.Count, 3).End(xlUp)).Value
For i = UBound(ComPrevNL, 1) To 2 Step -1
tmp = ComPrevNL(i, 1)
On Error Resume Next
CollPrevNL.Add tmp, CStr(tmp)
On Error GoTo 0
For j = 2 To UBound(ComNL, 1)
If ComNL(j, 1) = tmp Then Exit For
Next j
If j > UBound(ComNL, 1) Then
.Rows(i).EntireRow.Delete [COLOR="SeaGreen"]'suppression d'un enregistrement obsolète[/COLOR]
Else
Sheets("NL").Rows(j).Copy Destination:=.Rows(i).Cells(1, 1) [COLOR="SeaGreen"]'actualisation d'un enregistrement existant[/COLOR]
End If
Next i
j = .Cells(.Rows.Count, 3).End(xlUp).Row
For i = 2 To UBound(ComNL, 1)
tmp = ComNL(i, 1)
On Error GoTo E
CollPrevNL.Add tmp, CStr(tmp)
On Error GoTo 0
j = j + 1
Sheets("NL").Rows(i).Copy Destination:=.Rows(j).Cells(1, 1) [COLOR="SeaGreen"]'ajout d'un enregistrement[/COLOR]
R: Next i
End With
Exit Sub
E:
On Error GoTo 0
Resume R
End Sub[/B][/COLOR]