Public Function REG(datecol As Range, hourscol As Range)
hrs = 0
For i = 2 To datecol.Row
dt = Application.WeekNum(Cells(i, datecol.Column), 2)
cdt = Application.WeekNum(Cells(datecol.Row, datecol.Column), 2)
If dt = 53 Then
dt = 1
End If
If cdt = 53 Then
cdt = 1
End If
If cdt = dt Then
hrs = hrs + Cells(i, hourscol.Column).Value
End If
If hrs <= 40 Then REG = Cells(datecol.Row, hourscol.Column) Else If (40 - (hrs - Cells(datecol.Row, hourscol.Column))) > 0 Then
REG = 40 - (hrs - Cells(datecol.Row, hourscol.Column))
Else
REG = 0
End If
End If
Next i
End Function
Public Function OVT(datecol As Range, hourscol As Range)
hrs = 0
For i = 2 To datecol.Row
dt = Application.WeekNum(Cells(i, datecol.Column), 2)
cdt = Application.WeekNum(Cells(datecol.Row, datecol.Column), 2)
If dt = 53 Then
dt = 1
End If
If cdt = 53 Then
cdt = 1
End If
If cdt = dt Then
hrs = hrs + Cells(i, hourscol.Column).Value
End If
If hrs > 40 Then
If (hrs - Cells(datecol.Row, hourscol.Column)) > 40 Then
OVT = Cells(datecol.Row, hourscol.Column)
Else
OVT = hrs - 40
End If
Else
OVT = 0
End If
Next i
End Function