Function SommeMois(Xan As Long, Xmois As Long, xtableau As Range) As Currency
Dim PremDuMois As Date, FinDuMois As Date, TotalTTC As Currency
Dim dateDeb As Date, dateFin As Date, xrow, i&, nj&
PremDuMois = DateSerial(Xan, Xmois, 1): FinDuMois = DateSerial(Xan, Xmois + 1, 1) - 1
For Each xrow In xtableau.Rows
nj = 0
For i = PremDuMois To FinDuMois: nj = nj - (i >= xrow.Cells(1, 3) And i <= xrow.Cells(1, 4)): Next
TotalTTC = TotalTTC + nj / (xrow.Cells(1, 4) - xrow.Cells(1, 3) + 1) * xrow.Cells(1, 5)
Next xrow
SommeMois = TotalTTC
End Function