ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Month -End Formula in VB (https://www.excelbanter.com/excel-programming/278246-re-month-end-formula-vbulletin.html)

Dianne

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.





All times are GMT +1. The time now is 01:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com