View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dianne Dianne is offline
external usenet poster
 
Posts: 107
Default Month -End Formula in VB

Function datEOM(datStartDate As Date, intNumMonths As Integer) As Date

Dim intIncrementYear As Integer
Dim intYear As Integer
Dim intMonth As Integer

intIncrementYear = Int((Month(datStartDate) + intNumMonths) / 12)
intYear = Year(datStartDate) + intIncrementYear
intMonth = Month(datStartDate) + intNumMonths + 1
If intMonth 12 Then intMonth = intMonth Mod 12

datEOM = DateSerial(intYear, intMonth, 1) - 1

End Function

--
Dianne

Hande & Tolga wrote:
We need to set the date of the month-end to a varaiable.
This function exists in excel EOMONTH but could not
achieve that in VB. We would like to know if there is
such a fuction or could be achieved with something else.