简体   繁体   中英

Need Excel Sheet to Calculate Complex Vacation Accrual and Use of Vacation Time

I've been working on this for a while and trying different styles... I need to develop a tracking spreadsheet (for 50 employees) that will calculate accruing vacation time and vacation time used based on the following parameters:

*Employees who have worked less than 3 years but past the 90 day anniversary with the company (at which they start accruing) (there is one more caveat on this... the accrual day is the 1st of the month of the month past the 90 days)[I figured this 90 day item out on my excel sheet] it will accrue at: - 4 hours a month, at the end of the month, with a MAX cap of 72 hours that they can have stored (but if they use vacation time and fall below the 72 hours they can continue to accrue again up to 72 hours...)

*Employees who have worked more than 3 years but less than 6 years with the company carry over their prior vacation and begin to accrue from here onward at: - 6.8 hours a month, at the end of the month, with a MAX cap of 122.4 hours that they can have stored (but if they use vacation time and fall below the 122.4 hours they can continue to accrue again up to 122.4 hours...)

*Employees 6 years and over with the company carry over their prior vacation and begin to accrue from here onward at: - 10 hours a month, at the end of the month, with a MAX cap of 180 hours that they can have stored (but if they use vacation time and fall below the 180 hours they can continue to accrue again up to 180 hours....)

& yes, I need to be able to deduct vacation time used.

Does anyone have any suggestions for layout or for a formula that can do part of these functions? I appreciate any advice or suggestion on what else I can use!

I have created a test sheet, and was accruing based on these conditions for the first and started on the second set of rules (for years 3+).

However when I accrue to the max of 72 hours on the first policy, it no longer accrues correctly if they used vacation and fall under the 72 hours cap again.

I know this is a overcomplicated policy, but that is what the company wants and they will not budge.... Any help or advice is appreciated. I know my sheet isn't great.. but I'm trying options.


Below is the equation I used for the 90 day:

=IF(F2<TODAY()-90, F2+90, "90 Day Period")

Then to get the first day of the month after I used:

=IF(G2="90 Day Period","N/A",DATE(YEAR(G2),MONTH(G2)+1,1))

I tried using for the accrual of the first rule (but it has issues...):

=IF(N2="N/A","N/A",IF(N2<=36,MIN(72,((N2*4)-P2),72),(72-P2)))

For second rule:

=IF(AND(N2>36,N2<=72),MIN(122.4,((N2-36)*6.8)+Q2-S2),0)

Let

  • column A EmpName
  • column B EntryDate
  • Column C DaysSpent for the current month
  • Column D capped Accruel buffer at end of month
  • repeat Columns C and D month after month

example

                        01-Sep-2013        01-Oct-2013
    EmpName EntryDate   spent       buffer spent       buffer ... etc ...
   .-------.-----------.-----------.------.-----------.------.
    me      01-Jan-2010           0     12           0   18.8
    you     01-Jun-2013           0      4           0      4

In order not to get spaghetti formulas I recommend to create some user defined functions in VBA, like

Function GetCap(EntryDate, ThisDate) As Single
Function GetMonthly(EntryDate, ThisDate) As Single

By experience it's easier to debug/maintain 2-3 nested If 's or Select Case 's in VBA than 92 character long formulas with no blanks, no comments etc. in the sheet. Should the business logic change, there's one code block to review - instead of dozens/hundreds of formula in a sheet that has grown for 3x12 months x 50 users.

The above functions may want the help of eg

Function EndOfMonth(MyDate) as Date
Function BeginOfNextMonth(MyDate) as Date

so that in the sheet you just

  • manually enter hours spent month after month
  • calculate new buffer as = MIN([oldbuffer] - [Spent] + GetMonthly(...), GetCap(...))
  • carefully use relative/absolute addressing to make the formula "copyable" across columns/rows, eg
    • row-absolute on ThisDate got from the header when copying downwards
    • column-absolute on EntryDate for each Emp when copying rightwards

You can of course use =GetCap(...) and =GetMonthly(...) directly in cells of your sheet to display intermediate results and for debugging purposes.

Be carefull when you compare dates

Tips :

  • 3 years later is not always 365x3 days later
  • check what the VBA DateSerial() functions does for months > 12 and months < 0
  • the end of next month always is the first days of 2 months ahead minus 1 ... even in February of a leap year ggg

    and post more questions if you get stuck on these functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM