Bonsoir le forum
A tester :
Option Explicit
Sub test()
Dim a, i As Long, w()
a = Sheets("Source 1").Range("a1").CurrentRegion.Value
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For i = 2 To UBound(a, 1)
If Not .exists(a(i, 1)) Then
.Item(a(i, 1)) = VBA.Array(a(i, 1), Empty, Empty, a(i, 4), Empty)
Else
w = .Item(a(i, 1)): w(3) = w(3) + a(i, 4)
.Item(a(i, 1)) = w
End If
Next
a = Sheets("Source 2").Range("a1").CurrentRegion.Value
For i = 2 To UBound(a, 1)
If Not .exists(a(i, 1)) Then
.Item(a(i, 1)) = VBA.Array(a(i, 1), Empty, Empty, Empty, a(i, 4))
Else
w = .Item(a(i, 1)): w(4) = w(4) + a(i, 4)
.Item(a(i, 1)) = w
End If
Next
a = .items: i = .Count
End With
Application.ScreenUpdating = False
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Synthese").Delete
On Error GoTo 0
Sheets.Add(after:=Sheets(Sheets.Count)).Name = "Synthese"
With Sheets("Synthese").Cells(1)
.Resize(1, 7).Value = Array("Clé", "Libellé 1", "Libellé 2", "Source 1", "Source 2", "Ecart", "OK/KO")
.Offset(1).Resize(i, 5).Value = Application.Index(a, 0, 0)
With .CurrentRegion
.Columns(.Columns.Count - 1).Offset(1).Resize(i) = "=rc[-2]-rc[-1]"
.Columns(.Columns.Count).Offset(1).Resize(i) = "=IF(RC[-1]=0,""OK"",""KO"")"
.Columns(.Columns.Count).HorizontalAlignment = xlCenter
.Font.Name = "calibri"
.Font.Size = 10
.VerticalAlignment = xlCenter
.BorderAround Weight:=xlThin
.Borders(xlInsideVertical).Weight = xlThin
With .Rows(1)
.BorderAround Weight:=xlThin
.Interior.ColorIndex = 38
.HorizontalAlignment = xlCenter
End With
.Columns.ColumnWidth = Array(6, 10, 10, 12, 12, 12, 8)
End With
.Parent.Activate
End With
Application.ScreenUpdating = True
End Sub
klin89