【发布时间】:2011-03-06 22:36:24
【问题描述】:
我正在尝试在 Excel 宏中显示毫秒。我有一列整数,它们是以毫秒为单位的时间戳(例如 28095200 是上午 7:48:15.200),我想在它旁边创建一个新列,以保持运行平均值并以 hh:mm:ss.000 格式显示时间。
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")
这只会在单元格中显示“mm:ss.0”。然而,当我单击单元格时,它会在公式栏中显示“hh:mm:ss”。为什么小时数不见了?如何显示小时、分钟、秒和毫秒?
【问题讨论】: