Hello There experts..Can somebody please help me on this. I am trying to calculate the total hours worked but if it will go beyond 12 midnight, it will not give me the correct time... please help me.. this is my codes..
my log in time is this 11/26/2018 8:29 and my log-out time is 11/27/2018 15:24
Dim FIRSTDATE As Date
Dim SECONDDATE As Date
Dim N As Long
Dim I As Integer
Dim LASTROW As Long
Dim WS As Worksheet
Set WS = Worksheets("DateTime")
LASTROW = WS.Cells(Rows.Count, 1).End(xlUp).Row
For I = 2 To LASTROW
If WS.Cells(I, 5) <> "" And WS.Cells(I, 6) <> "" Then
FIRSTDATE = TimeValue(WS.Cells(I, 5))
SECONDDATE = TimeValue(WS.Cells(I, 6))
N = DateDiff("S", FIRSTDATE, SECONDDATE)
WS.Cells(I, 7) = N
WS.Cells(I, 7) = Cells(I, 7) / 3600
WS.Cells(I, 7) = Round(Cells(I, 7))
UserForm4.TextBox1.Value = WS.Cells(I, 7)
End If
Next I
Bookmarks