Verilen tarihe ait ayın son gününü sayı olarak veren VBA kodudur.
Option Explicit
Public Function AyinSonGunu(ByVal tarih As Date) As Byte
Dim sonGun As Byte
sonGun = DatePart("d", DateAdd("d", -1, DateAdd("m", 1, DateAdd("d", -DatePart("d", tarih) + 1, Date))))
AyinSonGunu = sonGun
End Function