OK this is annoying me.
The If condition is satisfied but jumps to the next one where the (O_Hrs + Time_Acc >8) when in fact it satisfies the (O_Hrs + Time_Acc <=8)
What on earth am i missing.
If (Time_Acc < 8) And (O_Hrs + Time_Acc <= 8) And (OT_Type = "New") Then
MYOB_Pre_Export.Cells(X, "A").Copy MYOB_Export.Cells(Y, "A")
MYOB_Pre_Export.Cells(X, "B").Copy MYOB_Export.Cells(Y, "B")
MYOB_Pre_Export.Cells(X, "C").Copy MYOB_Export.Cells(Y, "C")
MYOB_Pre_Export.Cells(X, "G").Copy MYOB_Export.Cells(Y, "G")
If MYOB_Pre_Export.Cells(X, "G") = "A - ANNUAL LEAVE" Then 'checks if its annual leave hours
MYOB_Export.Cells(Y, "D") = ".Holiday Pay Hourly"
Else
If MYOB_Pre_Export.Cells(X, "G") = "A - SICK LEAVE" Then 'checks if its sick leave hours
MYOB_Export.Cells(Y, "D") = ".Sick Pay Hourly"
Else
MYOB_Export.Cells(Y, "D") = "..Base Hourly"
End If
End If
If (lunch_break = 0) And (Time_Acc + O_Hrs > 5) Then 'checks to see if lunch break flag is not set and the worked time greater than 5 hours
C_Hrs = (O_Hrs - 0.5) 'deducts luch break
lunch_break = 1
Else
C_Hrs = O_Hrs 'no lunch break deducted
End If
MYOB_Export.Cells(Y, "F") = C_Hrs
Y = Y + 1
Else
If (Time_Acc < 8) And (O_Hrs + Time_Acc > 8) And (O_Hrs + Time_Acc < 10) And (OT_Type = "New") Then
MYOB_Pre_Export.Cells(X, "A").Copy MYOB_Export.Cells(Y, "A")
MYOB_Pre_Export.Cells(X, "B").Copy MYOB_Export.Cells(Y, "B")
MYOB_Pre_Export.Cells(X, "C").Copy MYOB_Export.Cells(Y, "C")
MYOB_Pre_Export.Cells(X, "G").Copy MYOB_Export.Cells(Y, "G")
MYOB_Export.Cells(Y, "D") = "..Base Hourly"
If (lunch_break = 0) And (Time_Acc + O_Hrs > 5) Then 'checks to see if lunch break flag is not set and the worked time greater than 5 hours
C_Hrs = ((8 - Time_Acc) - 0.5) 'deducts lunch break
lunch_break = 1
Else
C_Hrs = (8 - Time_Acc)
End If
VBA If condition fail.png
Bookmarks