Yes, it is/was
So to improve readability:
Code:Function xlDATEDIF(ByVal StartDate As Date, ByVal EndDate As Date, Interval As String) As Long If StartDate < EndDate Then sp = Split("Y|M|D|YY|MM|DD", "|") sn = Array(0, 0, 0, 0, 0, 0) sn(0) = Year(EndDate) - Year(StartDate) sn(1) = DateDiff("m", StartDate, EndDate) sn(2) = EndDate - StartDate sn(3) = Year(EndDate) - Year(StartDate) - IIf(100 * Month(StartDate) + Day(StartDate) > 100 * Month(EndDate) + Day(EndDate), 1, 0) sn(4) = DateDiff("m", StartDate, EndDate) - IIf(Day(StartDate) > Day(EndDate), 1, 0) sn(5) = EndDate - StartDate - IIf(Format(StartDate, ",0000") * 1 > Format(EndDate, ",0000") * 1, 1, 0) xlDATEDIF = sn(Application.Match(Interval, sp, 0) - 1) Else Err.Raise 5 End If End Function




Reply With Quote

Bookmarks