LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default VBA Timer

I think you can't make it with only t0 and t1, you'll need t2 & t3 too...


Public Sub YourSub()
Dim t0, t1, t2, t3
'5 seconds
t0 = 5
t1 = Timer
Do While Timer < (t1 + t0)
DoEvents
t3 = (t1 + t0) - Timer
Sheets(1).Cells(1, 1).Value = Round(t3, 0)
Loop
End Sub





"Lisa" schreef in bericht
...
Thanks Moon,
I appreciate your help but is there not a simpler way to achieve this?
I'm sure your code will work but I understand very little of it and , as
a newbie, I need to learn in small doses.

Is it not possible to do it as I originally set it out?
i.e. at start t0 = current time
during loop t1 = current time
during loop shove the difference between t0 & t1 into a cell on the
worksheet

As I said, I appreciate any help but I can't help feeling that there must
be a simpler way.

Best Reagrds
Lisa


"moon" wrote in message
. ..

Private Sub YourSub()
Dim pTime, pStart, pEnd, tTime, lTime
'five seconds
pTime = 5
pStart = Timer
Do While Timer < pStart + pTime
DoEvents
lTime = (pStart + pTime) - Timer
'update label (or anything else)
timeLabel.Caption = Round(lTime, 0)
Loop
pEnd = Timer
tTime = pEnd - pStart
End Sub




"Lisa" schreef in bericht
...
Hi All,

I'm looking for a simple timer routine that will show the time elapsed
for each cycle of a Do Until ...Loop instruction. (the loop can go on
for many millions of cycles)

I'm thinking of something like :-

Before the *Do Until* starts t0 = current time

For each cycle within the loop t1 = current time and
Cells(1,1,) = t1-t0

But how?

Many thanks

Lisa

BTW I'm using XL97







 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
timer Steve[_9_] Excel Discussion (Misc queries) 4 January 28th 08 08:10 PM
Timer Vijay Excel Worksheet Functions 1 April 6th 07 11:00 AM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
timer Mike Macgowan Excel Programming 4 May 24th 05 03:27 AM
timer nyn04[_7_] Excel Programming 1 September 23rd 04 12:04 PM


All times are GMT +1. The time now is 12:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"