Hi all,
I have the following code that might be a bit rough, but runs. The purpose of this part of the macro is call a conditional formatting subroutine and to then find the difference in value between two dates.
What I can't do is add 1 to the difference in the dates.
The point of it all is for a 'time in leiu tracking spreadsheet', therefore if someone takes only one day off, they enter the same date twice and the value is 0 when is should be 1 (for one day) and so on.
Any input would be great, I think my issue is trying to peform math functions within VBA on date values. Eitherway, its done my head in.
----------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("D16:D100", "E16:E100")) Is Nothing Then
Call DateCheck
End If
If IsEmpty(Cells(Target.Row, "D")) = False And IsEmpty(Cells(Target.Row, "E")) = False Then
If Cells(Target.Row, "E") > Cells(Target.Row, "D") Then
Cells(Target.Row, "F") = Cells(Target.Row, "E") - Cells(Target.Row, "D")
End If
End If
End Sub
---------------------------
Cheers,
Tim.
I have the following code that might be a bit rough, but runs. The purpose of this part of the macro is call a conditional formatting subroutine and to then find the difference in value between two dates.
What I can't do is add 1 to the difference in the dates.
The point of it all is for a 'time in leiu tracking spreadsheet', therefore if someone takes only one day off, they enter the same date twice and the value is 0 when is should be 1 (for one day) and so on.
Any input would be great, I think my issue is trying to peform math functions within VBA on date values. Eitherway, its done my head in.
----------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("D16:D100", "E16:E100")) Is Nothing Then
Call DateCheck
End If
If IsEmpty(Cells(Target.Row, "D")) = False And IsEmpty(Cells(Target.Row, "E")) = False Then
If Cells(Target.Row, "E") > Cells(Target.Row, "D") Then
Cells(Target.Row, "F") = Cells(Target.Row, "E") - Cells(Target.Row, "D")
End If
End If
End Sub
---------------------------
Cheers,
Tim.