Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim an%, mois As Byte, jour As Byte
If Intersect(Range("B3:AF" & Rows.Count), ActiveCell) Is Nothing Or Not IsDate(Cells(ActiveCell.Row, 1)) Then Exit Sub
an = Year(Cells(ActiveCell.Row, 1))
mois = Month(Cells(ActiveCell.Row, 1))
jour = Cells(2, ActiveCell.Column)
[A1].NumberFormat = "dd/mm/yyyy"
[A1] = Application.Min(DateSerial(an, mois, jour), DateSerial(an, mois + 1, 0))
End Sub