Option Explicit
Private Sub Command1_Click()
MsgBox GetLastDate(Date)
End Sub
Public Function GetLastDate(aDate As String) As String
Dim strTmp As String
aDate = DateAdd("m", 1, aDate)
strTmp = Year(aDate) & "/" & Month(aDate) & "/1"
GetLastDate = DateAdd("d", -1, strTmp)
' MsgBox InStrRev(GetLastDate, "-")
GetLastDate = Mid(DateAdd("D", -1, strTmp), InStrRev(GetLastDate, "-") + 1)
End Function