Re Prypry,
J'ai rectifié le tir
Je m'appuie sur les 2 feuilles "Balances"
Option Explicit
Sub Balance()
Dim a, i As Long, w()
a = Sheets("balances").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), a(i, 3), Empty)
Else
w = .Item(a(i, 1)): w(1) = w(1) + a(i, 3)
.Item(a(i, 1)) = w
End If
Next
a = Sheets("Balance N-1").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, a(i, 3))
Else
w = .Item(a(i, 1)): w(2) = w(2) + a(i, 3)
.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"
Sheets("Synthese").Cells(1).Resize(1, 3).Value = Array("Compte", "N", "N-1")
Sheets("Synthese").Cells(1).Offset(1).Resize(i, 3).Value = Application.Index(a, 0, 0)
With Sheets("Synthese").Cells(1).CurrentRegion
.Sort key1:=.Cells(1), order1:=1, Header:=xlYes
.Font.Name = "calibri"
.Font.Size = 10
.VerticalAlignment = xlCenter
.BorderAround Weight:=xlThin
.Borders(xlInsideVertical).Weight = xlThin
With .Rows(1)
.BorderAround Weight:=xlThin
.Interior.ColorIndex = 38
End With
.Columns.AutoFit
End With
Application.ScreenUpdating = True
End Sub
klin89