Function Sigma(dat$, MF$, plage As Range)
Dim mois As Byte, ncol As Variant, nlig&, tabdat, j%, tabMF, tablo, i&
mois = Month("1/" & dat)
ncol = Application.Match(9 ^ 9, plage.Rows(1))
If IsError(ncol) Then ncol = 1
ncol = ncol + plage(1, ncol).MergeArea.Count - 1
If ncol = 1 Then ncol = 2 'au moins 2 cellules
nlig = Application.Match("zzz", plage.Columns(-1)) 'en colonne A
Set plage = plage.Resize(nlig, ncol)
tabdat = plage.Rows(1)
If MF <> "" Then
For j = 1 To ncol
If tabdat(1, j) = "" Then tabdat(1, j) = plage(1, j).MergeArea(1)
Next j
End If
tabMF = plage.Rows(2) 'matrice, plus rapide
tablo = plage 'matrice, plus rapide
For i = IIf(MF = "", 2, 3) To nlig
For j = 1 To ncol
If IsNumeric(tablo(i, j)) Then _
If IsDate(tabdat(1, j)) Then _
If Month(tabdat(1, j)) = mois Then _
If MF = "" Or tabMF(1, j) = Left(MF, 1) Then Sigma = Sigma + tablo(i, j)
Next j, i
End Function