You are welcome!
Code:
Dim TotHours As Double
Dim rngData As Range
Dim CutOff As Double
CutOff = 8
If Application.WorksheetFunction.Weekday(DTPicker1, 2) = 5 Then CutOff = 6 'for Friday
With Worksheets("Data")
Set rngData = .Range("c2:i" & .Range("c" & .rows.Count).End(xlUp).Row)
End With
TotHours = Application.WorksheetFunction.SumIfs(rngData.Columns(7), rngData.Columns(1), CDate(Reg1.Value), rngData.Columns(3), Reg3.Value, rngData.Columns(4), Reg4.Value)
TotHours = TotHours + CDbl(Reg7.Value)
Label29 = TotHours
If TotHours > CutOff Then
MsgBox "Your warning message", vbExclamation
Exit Sub
End If
Label32 = CutOff - TotHours
Bookmarks