Hello,
I create a macro to calculate the time travel between two times which are attendance records;
To calculate the difference between B and A
So in this case we havec 3 conditions :
- B is greater than A so you can make de substraction
- Or B is less than A so it's an error from the system, you have to return the message "error" on the cell
- Or there is no value on B so you have to letthe cell blank
But when I'm runing this code the macro doesn't consider the last condition :
Please can someone help me on this
I create a macro to calculate the time travel between two times which are attendance records;
To calculate the difference between B and A
So in this case we havec 3 conditions :
- B is greater than A so you can make de substraction
- Or B is less than A so it's an error from the system, you have to return the message "error" on the cell
- Or there is no value on B so you have to letthe cell blank
But when I'm runing this code the macro doesn't consider the last condition :
VBA Code:
Sub Trial()
LastLine = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastLine
If (Range("B" & i)) > (Range("A" & i)) Then
Sheets("Sheet_1").Range("F" & i).FormulaR1C1 = "=RC[-4]-RC[-5]"
ElseIf IsEmpty(Range("E" & i)) = True Then
'Leave the cell blank
ElseIf (Range("B" & i)) < (Range("A" & i)) Then
Range("F" & i) = "Error"
End If
Next i
End Sub
Please can someone help me on this