简体   繁体   English

需要Excel工作表来计算复杂的假期应计和假期时间的使用

[英]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: 我已经为此进行了一段时间的尝试,并尝试了不同的样式...我需要开发一个跟踪电子表格(适用于50名员工),该电子表格将根据以下参数计算应计休假时间和所使用的休假时间:

*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...) *在公司工作不到三年但超过90天周年纪念日的员工(他们开始应聘时)(此事还有其他警告……应聘日是指该月之后的当月的第一个月) 90天)[我在excel工作表中算出了这90天的项目],它将在以下时间产生:-月底每月4小时,他们可以存储的最大上限为72小时(但如果他们使用休假时间并降至72小时以下,他们最多可以继续累积72小时...)

*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...) *在公司工作超过3年但不到6年的员工会保留之前的假期,并从这里开始累积:-月底每月6.8个小时,最高上限为122.4他们可以存储的小时数(但是如果他们使用休假时间并低于122.4小时,则可以继续累积最多122.4小时...)

*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....) *在公司工作了6年及以上的员工可以休假,并从这里开始累积:-月底每月10个小时,最多可以存储180个小时(但如果他们使用休假时间并低于180小时,则可以继续累积最多180小时。...)

& 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+). 我已经创建了一张测试表,并根据这些条件在第一组中进行了累积,并从第二组规则开始(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. 但是,当我在第一个保单上最多累积72小时时,如果他们使用休假并再次落在72小时上限之内,它将不再正确累积。

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: 以下是我90天使用的方程式:

=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 列A EmpName
  • column B EntryDate B列EntryDate
  • Column C DaysSpent for the current month 列C当月花费的天数
  • Column D capped Accruel buffer at end of month 月底D列上限为Accruel缓冲区
  • repeat Columns C and D month after month 每月重复C和D列

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 为了不获取意大利面条式,我建议在VBA中创建一些用户定义的函数,例如

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. 根据经验,在工作表中调试/维护2-3个嵌套的IfSelect Case比在92个字符长的公式中没有空格,没有注释等要容易得多。 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. 如果业务逻辑发生变化,则只需要审查一个代码块-而不是在增长3x12个月x 50个用户的工作表中使用数十个/百个公式。

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(...)) 计算新缓冲区为= 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 向下复制时, ThisDate上的行绝对是从标头获得的
    • column-absolute on EntryDate for each Emp when copying rightwards 向右复制时,每个Emp的EntryDate上的列绝对值

You can of course use =GetCap(...) and =GetMonthly(...) directly in cells of your sheet to display intermediate results and for debugging purposes. 当然,您可以直接在工作表的单元格中使用=GetCap(...)=GetMonthly(...)以显示中间结果并用于调试目的。

Be carefull when you compare dates 比较日期时要小心

Tips : 温馨提示

  • 3 years later is not always 365x3 days later 3年后并非总是365x3天后
  • check what the VBA DateSerial() functions does for months > 12 and months < 0 检查VBA DateSerial()函数在大于12的月份和小于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 下个月月底总是提前2个月减去1的前几天......甚至在闰年GGG二月

    and post more questions if you get stuck on these functions. 如果您对这些功能感到困惑,请发表更多问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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