2014-09-01 52 views
-1

我正在为考勤考勤工作。除了一件事外,我大部分都想通了。员工每周为我们工作的第一年,他们最多可获得两个小时的休假时间。如果他们在本周有完美的出勤率,则可以获得一个小时。如果他们在优先的日子上班,即使他们迟到,第二个小时也会赚取。我很难想出办法来检查这两个小时。我有一张表,列出星期一开始的工作周。在考勤跟踪器中加入考试时间

我之所以想要完美出席,是为了查找A列中出现的所有出席日期,这些日期位于问题的开始日期和下周的开始日期之间(K列),然后检查它是否为在列E中列为无效。但我不知道如何设置它。

enter image description here

回答

0

我已经重新安排列,并没有使用所有的人,因为我不知道如何相关的一些手头上的问题。列A,B,C和D是输入。我将“优先级”值从yes/no更改为True/False。 “查找周”按钮激活下面的宏中的列E.填补

Sub findweek() 

Dim absence As Integer: Dim week As Byte 

Range("E2:E100").ClearContents 

    absence = 2 'find the first absence in column A 

    week = 2 'find the first week in column B 

     Do While Cells(absence, 1) <> 0 'loop through the absences in column A 

      Do While Cells(week, 4) <> 0 'loop through weeks in column B 

'compare the date in column A to the begining of week in column B 

      If Cells(absence, 1) > Cells(week, 4) Then 
       week = week + 1 
      ElseIf Cells(absence, 1) = 0 Then 
       Exit Do 
      Else 
       Cells(week - 1, 5) = Cells(absence, 1): absence = absence + 1: week = 2 
      End If 

      Loop 'count until you run out of "Mondays" 

     Exit Do 
     Loop 'count until you run out of "dates" 

End Sub 

的值F栏由以下填充:

=IF(E2="",1,IF(VLOOKUP(E2,$A$2:$C$100,3,FALSE)=TRUE,2,0)) 

细胞G1款项列F中的值

我希望这会给你一个关于如何设置项目的想法。

Column letters and Row numbers are not pictured