Private Sub Worksheet_Calculate()
Dim nom$, an%, mois As Byte, t, a(), i&, n&
If [B1] <> "" And [B2] <> "" Then
nom = [B1]
an = Year(DateValue("1 " & [B2]))
mois = Month(DateValue("1 " & [B2]))
t = [Tableau1]
ReDim a(1 To UBound(t), 1 To 6)
For i = 1 To UBound(t)
If Year(t(i, 1)) = an And Month(t(i, 1)) = mois And t(i, 2) = nom Then
n = n + 1
a(n, 1) = t(i, 1): a(n, 2) = t(i, 3)
a(n, 3) = t(i, 4): a(n, 4) = t(i, 5)
a(n, 5) = t(i, 6): a(n, 6) = a(n, 5) - a(n, 4)
End If
Next i
End If
'---restitution et mise en forme---
Application.ScreenUpdating = False
Application.EnableEvents = False
Range("A8:F" & Rows.Count).Delete xlUp 'RAZ
If n Then
[A8].Resize(n, 6) = a
[F1] = Application.Sum(Application.Index(a, , 6))
[A8].Resize(n, 6).Borders.Weight = xlThin
End If
Application.EnableEvents = True
End Sub