Hi,
There's no formula that I know of that will cater for what you are looking
for. What you can use is a VBA function to calculate the month difference.
Try something like the below function (paste the below into a module)
'To use on an Excel worksheet type =Months(A1,D1) where A1 represents the
first date
'and D1 represents the second date
Public Function Months(Date1 As Date, Date2 As Date) As Long
Dim iMonthCount As Long, sYear As Long, eYear As Long, sMonth As Long,
eMonth As Long
sMonth = Month(Date1)
eMonth = Month(Date2)
sYear = Year(Date1)
eYear = Year(Date2)
If sMonth = eMonth Then
iMonthCount = Abs(sMonth - eMonth)
If sYear eYear Then
iMonthCount = ((sYear - eYear) * 12) + iMonthCount
ElseIf sYear < eYear Then
iMonthCount = ((Abs(sYear - eYear)) * 12) - iMonthCount
End If
ElseIf eMonth sMonth Then
iMonthCount = Abs(eMonth - sMonth)
If sYear eYear Then
iMonthCount = ((sYear - eYear) * 12) - iMonthCount
ElseIf sYear < eYear Then
iMonthCount = ((Abs(sYear - eYear)) * 12) + iMonthCount
End If
End If
Months = iMonthCount
End Function
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200906/1