
Originally Posted by
Smd747
First hiccup with the new code. It does not account for overnight . When I click active cell 6:00 PM and ending cell 2:30 AM it give me 16 hours
Try it like this and let me know if it works for you or not...
Code:
Sub GetStartEndTime2()
Dim StartTime As Date, EndTime As Date, BreakTime As Long, TimeDiff As String
StartTime = ActiveCell.Value
EndTime = Application.InputBox("Select the cell with the ending time...", Type:=8)
BreakTime = 60 'Not sure how you plane to calculate 30 or 60, but it goes here
TimeDiff = Format(24 + EndTime - StartTime - TimeSerial(0, BreakTime, 0), _
"h"" hours and ""m"" minutes which excludes a " & BreakTime & " minute break.""")
MsgBox "Start time: " & StartTime & vbLf & "End time: " & EndTime & vbLf & "Time difference: " & TimeDiff
End Sub
Bookmarks