1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| '@Description "Renvoie les dates d'anniverssaires formatées"
Public Function DisplayBirthday(Optional ThisDate As Date) As String
Dim itemRange As Excel.Range
For Each itemRange In sys_Datas.Range("vt_Clients[Date anniversaire]")
With itemRange
If Month(.Value) = Month(Date) And Day(.Value) = Day(Date) Then
Dim TempString As String
TempString = TempString & .Offset(0, -1).Value & Space(2) & DateDiff("yyyy", .Value, Date) & " ans" & vbNewLine
End If
End With
Next itemRange
If TempString > vbNullString Then
DisplayBirthday = "Bonjour, aujourd'hui c'est l'anniversaire de :" & vbNewLine & TempString
Else
DisplayBirthday = "Bonjour, pas d'aniverssaire à fêter aujourd'hui !"
End If
End Function |