Answers for "excel vba last day of month"

VBA
4

excel vba last day of month

' Returns last day of month
Public Function LastDayOfMonth(ByVal pDate As Date) As Date
    LastDayOfMonth = DateSerial(Year(pDate), Month(pDate) + 1, 0)
End Function

' Returns first day of month
Public Function FirstDayOfMonth(ByVal pDate As Date) As Date
    FirstDayOfMonth = DateSerial(Year(pDate), Month(pDate), 1)
End Function
' ---------------------------------------------------------------
Public Sub TestMe()
    MsgBox LastDayOfMonth(Date)
    MsgBox FirstDayOfMonth(DateSerial(2020, 2, 18))
End Sub
Posted by: Guest on January-19-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language