1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| 'test entery data
'check the blanks
If Me.Txtprojectname.Value = "" Or Me.cbxtaskstartdate.Value = "" Or Me.cbxtaskenddate.Value = "" Or Me.Txtprojectid.Value = "" Or Me.cbxprojectmanager.Value = "" Or Me.Cbxdomain.Value = "" Then
MsgBox "Complete the blank(s)"
Exit Sub
End If
'Check the Date
If CDate(cbxtaskenddate) < CDate(cbxtaskstartdate) Then
MsgBox "Enter new date"
Exit Sub
Else:
Date1 = Me.cbxtaskstartdate.Value
Date2 = Me.cbxtaskenddate.Value
'Check hours field is a number
If Not Me.txttaskhour.Value.IsNumber Then
Exit Sub
MsgBox "Hours field should be a number"
End If
'Check the coherence between the working-day and the number of hours
'Compute working-day
Count = 0
For i = Date1 To Date2 Step 1
If Weekday(i, vbMonday) <= 5 Then
Count = Count + 1
Next i
'Check UK holiday
Sheets("UK_holiday").Select
h = 0
C = False
Do
h = 1 + h
If Cells(h + 2, 1) >= Date1 And Cells(h + 2, 1) <= Date2 Then
Count = Count - 1
C = True
End If
Loop While Cells(h + 3, 1) <> ""
'Check workhours
Workhour = Hours / Count
If While workhours > 8 then
MsgBox "Too much working hours for the actual date interval"
MsgBox "Enter new Hour values or new date interval"
If C = True Then
MsgBox "Take care of the UK holiday"
End if
Exit Sub
End if
End If |