View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Grab Time with milliseconds included in VBA

Hi Erick,

If you are trying to return the time like a stopwatch you could use the
following API which returns the time in milliseconds since system startup:

Public Declare Function GetTickCount Lib "kernel32.dll" () As Long
Sub testTimer()
Dim t As Long
t = GetTickCount

For i = 1 To 1000000
a = a + 1
Next

MsgBox GetTickCount - t, , "Milliseconds"
End Sub

Regards,
Peter

"Erick" wrote in message
om...
I read one post that had a formula like "=TEXT(NOW(),"SS.00")", that
works, but I can not find anyway to use VBA to include milliseconds in
the time. I have tried worksheets("sheet1").cells(1,1) =
format(Time,"SS.00") and simular code but still can not get vba to
give me the milliseconds.


Thank you,
EKlassen