2014-09-01 53 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