I have a worksheet where there are From and To times like 4:37:04 PM and 4:39:20 PM in several rows. The times are based on Now() with a NumberFormat of "h:mm:ss am/pm". The To time is triggered by a timer that runs every second and in the Worksheet_Change event for the worksheet I easily determine the duration when the To time changes with this code.
And using those values the Duration comes out as 2 min 16 sec using this codeCode:dteDiff = Cells(Target.Row, "G") - Cells(Target.Row, "F") lngHours = CLng(Hour(dteDiff)) lngMinutes = CLng(Minute(dteDiff)) lngSeconds = CLng(Second(dteDiff))
I would also like to produce a total duration for all the rows. How would I do that in some efficent way given that the code is running every second?Code:Cells(Target.Row, "H") = lngMinutes & " min " & lngSeconds & " sec"




Reply With Quote