AusSteelMan
Board Regular
- Joined
- Sep 4, 2009
- Messages
- 208
Hi guys,
Just a small one I can't get right.
The problem is if the "Workday" cell is left empty, the date is seen as 12:00:00 AM according to the watch, not 0.
What do I need to change in the following line to make it valid
I tried a few things (incl Nothing, "12:00:00 am" amongst others) but can't get it.
Everything is OK if the hours are 0 and the calcs work properly when both are valid arguments, just doesn't work how I intended if there is no date (or even if it is text: although I am happy if text is entered for the result to be #VALUE!)
Any help appreciated
Thanks
ASM
Just a small one I can't get right.
Code:
Public Function OtHours(Workday As Date, Hours As Single)
Dim DayNumber As Integer
DayNumber = Weekday(Workday, vbSunday)
If Hours = 0 Then OtHours = 0
If Workday = 0 Then OtHours = 0
If DayNumber = 1 Then
OtHours = Hours * 2
Else
If Hours > 2 Then
OtHours = 3 + ((Hours - 2) * 2)
Else
OtHours = Hours * 1.5
End If
End If
End Function
The problem is if the "Workday" cell is left empty, the date is seen as 12:00:00 AM according to the watch, not 0.
What do I need to change in the following line to make it valid
Code:
If Workday = 0 Then OtHours = 0
I tried a few things (incl Nothing, "12:00:00 am" amongst others) but can't get it.
Everything is OK if the hours are 0 and the calcs work properly when both are valid arguments, just doesn't work how I intended if there is no date (or even if it is text: although I am happy if text is entered for the result to be #VALUE!)
Any help appreciated
Thanks
ASM