Sub MiseAJourContrats()
Dim WbDest As Workbook
Dim shDest As Worksheet
Dim PlageSource As Range, PlageDest As Range, cSource As Range, cDest As Range
With Sheets("Table")
Set PlageSource = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row)
End With
'Si le classeur n'est pas là sortir
If Dir(ThisWorkbook.Path & "\Fichier à renseigner.xls") = "" Then Exit Sub
'Ouverture du classeur
Set WbDest = Workbooks.Open(ThisWorkbook.Path & "\Fichier à renseigner.xls")
'La feuille à renseigner
On Error Resume Next
Set shDest = WbDest.Sheets("A renseigner")
On Error GoTo 0
'Si elle n'existe pas sortir
If shDest Is Nothing Then Exit Sub
'Déterminer la plage des numéro de contrat
With shDest
Set PlageDest = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row)
End With
For Each cSource In PlageSource.Cells
Set cDest = PlageDest.Find(what:=cSource, LookIn:=xlValues, lookat:=xlWhole)
If Not cDest Is Nothing Then
With cDest
.Value = cSource.Offset(, 1) 'Nouveau Numéro de contrat
.Offset(, 2) = cSource.Offset(, 2) 'Date Fin
End With
End If
Next cSource
End Sub