Livin404
Well-known Member
- Joined
- Jan 7, 2019
- Messages
- 743
- Office Version
- 365
- 2019
- Platform
- Windows
Greetings, In Column F on a worksheet I'm trying to get Column F to be expressed in terms of hours and minutes. For example 1 and 45 mintues. I would like it to read 1.45. If something takes 2 hours and 8 minutes. It would be entered as 2.08. The minutes can only go up to .59. Eventually these time durations will be be added together. For example1.45 and 2.08 would be 3.53. Naturally if the number goes over 59 than the hour will be increased. I already set Column F with a Custom number h:mm. I tried to use the following VBA but I"m afraid I'm falling well short of the mark. Any help would be greatly appreciated.
VBA Code:
Sub elapsedtime()
Dim rng As Range
Set rng = ActiveSheet.Range("F2:F500") '.SpecialCells(xlConstants, xlNumbers)
For Each c In rng
If c.Value >= 1 And Int(c.Value) = c.Value Then _
c.Value = (c.Value / 86400)
Next c
Columns("D:D").Select
Selection.NumberFormat = "mm:ss.0"
End Sub