' La BdD
Function NbEnfant(ColDate As Range, AgeMin As Integer, AgeMax As Integer, MoisNaissance As Integer, QuelleAnnée As Integer)
Dim Cel As Range, Cpt As Integer
Dim AgeAnniv As Integer, DateAnniv As Date
Application.Volatile
Cpt = 0
For Each Cel In ColDate
If Month(Cel) = MoisNaissance Then
' Calculer l'age à l'année choisi de la cellule
DateAnniv = DateSerial(QuelleAnnée, Month(Cel), Day(Cel))
AgeAnniv = DateDiff("yyyy", Cel, DateAnniv)
If AgeAnniv >= AgeMin And AgeAnniv <= AgeMax Then Cpt = Cpt + 1
End If
Next Cel
' Retourner le nombre d'enfants trouvés
NbEnfant = Cpt
End Function