I am trying to a) create a time with millisecond accuracy and b) display that in Excel.
What I have found using the below code is that Excel will show the correct milliseconds in the worksheet using the NumberFormat "DD/MM/YYYY HH:MM:SS.000" but it will not show milliseconds in the debug window using the 'Format' command and instead rounds it up to the nearest second.
Can anyone else confirm this to be a known issue or have they got experience of this ?
Sub testMilliseconds() Dim dblMillisecond As Double Dim dblResult As Double dblMillisecond = 1.15740740740741E-08 dblResult = dblMillisecond * 1750 Debug.Print Format(dblResult, "DD/MM/YYYY HH:MM:SS.000") With Range("A1") .Value = dblResult .NumberFormat = "DD/MM/YYYY HH:MM:SS.000" End WithEnd Sub
It s a known issue if you want to calculate time lapse
Open in new windowRegards