I am trying to display milliseconds in an Excel macro. I have a column of integers which are timestamps in milliseconds (e.g. 28095200 is 7:48:15.200 am), and I want to make a new column next to it which keeps a running average and displays the time in a hh:mm:ss.000
format.
Dim Cel As Range
Set Cel = Range("B1")
temp = Application.Average(Range("A1:A2")) / 1000
ms = Round(temp - Int(temp), 2) * 1000
Cel.Value = Strings.Format((temp / 60 / 60 / 24), "hh:mm:ss") _
& "." & Strings.Format(ms, "#000")
This only displays "mm:ss.0" in the cell. Yet when I click on the cell, it shows "hh:mm:ss" in the formula bar. Why are the hours missing? How can I show the hours, minutes, seconds, and milliseconds?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…