I believe that you can solve this one with a user defined function.
Function AccrualThisYear(HireDate As Range) As Single
Dim AnniversaryDate As Date
Dim ServiceAtAnniverary As Integer
Dim BeforeAnniverary As Single
Dim AfterAnniverary As Single
AnniversaryDate = DateValue(Left(HireDate, 6) & Year(Now()))
ServiceAtAnniverary = Round((AnniversaryDate - HireDate) / 365.5)
If AnniversaryDate < Date Then
Select Case ServiceAtAnniverary - 1
Case Is < 1
AccrualRate = 0.769
Case Is < 5
AccrualRate = 1.538
Case Is >= 5
AccrualRate = 2.307
End Select
BeforeAnniverary = ((AnniversaryDate - DateValue("01/01/" & Year(Now()))) / 7) * AccrualRate
Select Case ServiceAtAnniverary
Case Is < 1
AccrualRate = 0.769
Case Is < 5
AccrualRate = 1.538
Case Is >= 5
AccrualRate = 2.307
End Select
AfterAnniverary = ((Date - AnniversaryDate) / 7) * AccrualRate
AccrualThisYear = BeforeAnniverary + AfterAnniverary
Else
Select Case ServiceAtAnniverary - 1
Case Is < 1
AccrualRate = 0.769
Case Is < 5
AccrualRate = 1.538
Case Is >= 5
AccrualRate = 2.307
End Select
AccrualThisYear = ((Date - DateValue("01/01/" & Year(Now()))) / 7) * AccrualRate
End If
End Function
To use this, open a new module in the VBA editor (Alt F11) and paste in the code.
In the spreadsheet enter a formula such as
Hope this works and that the members of the Doe family enjoy their holidays.
Bookmarks