Sub Update()
Dim tab2019() As Variant
Dim tab2020() As Variant
Dim tabMaJ() As Variant
Set dico2019 = CreateObject("scripting.dictionary")
Set dico2020 = CreateObject("scripting.dictionary")
Set dicoMaj = CreateObject("scripting.dictionary")
With Sheets("2019")
fin = .Range("A" & .Rows.Count).End(xlUp).Row
tab2019 = .Range("A3:G" & fin).Value
For i = LBound(tab2019, 1) To UBound(tab2019, 1)
If Not dico2019.exists(tab2019(i, 1)) Then dico2019.Add tab2019(i, 1), i
Next i
End With
With Sheets("2020")
fin = .Range("A" & .Rows.Count).End(xlUp).Row
tab2020 = .Range("A3:G" & fin).Value
For i = LBound(tab2020, 1) To UBound(tab2020, 1)
If Not dico2020.exists(tab2020(i, 1)) Then dico2020.Add tab2020(i, 1), i
Next i
End With
With Sheets("Mise à jour")
fin = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("C3:G" & fin).ClearContents
tabMaJ = .Range("A3:G" & fin).Value
For i = LBound(tabMaJ, 1) To UBound(tabMaJ, 1)
If Not dicoMaj.exists(tabMaJ(i, 1)) Then dicoMaj.Add tabMaJ(i, 1), i
Next i
End With
For i = LBound(tabMaJ, 1) To UBound(tabMaJ, 1)
If dico2019.exists(tabMaJ(i, 1)) Then
If dico2020.exists(tabMaJ(i, 1)) Then
For j = 3 To UBound(tabMaJ, 2)
tabMaJ(i, j) = tab2020(dico2020(tabMaJ(i, 1)), j)
Next j
Else
For j = 3 To UBound(tabMaJ, 2)
tabMaJ(i, j) = ""
Next j
End If
End If
Next i
With Sheets("Mise à jour")
.Range("A3").Resize(UBound(tabMaJ, 1), UBound(tabMaJ, 2)) = tabMaJ
End With
End Sub