Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Vernon Day   on Jan 09 In MS Office Category.

  
Question Answered By: Elliot Evans   on Jan 09

This can be done, and it's not difficult, but I wouldn't advise
refreshing it every second.
First: It's very unlikely that you are doing ANYTHING in a loop that
will cycle every second. so, the Application.Statusbar statement will
not execute every second.
Second: Screen refreshes are VERY time-expensive!
Let's say you're retrieving 1,000 records and it takes about 30-45 seconds
to process. If you're updating  every second, your cycle time  could
be 3-5 MINUTES!
I usually do something like this while testing, then change it to update
about every 100 or 1000 records (depending on the query)

If you still want to do it, what I would do is:
Sub StatTest()
Dim tStart, tStop
Dim tHrs, tMin, tSec, tElapsed
tStart = Timer
'tStart = 20000.2 '(for testing purposes only)
For I = 1 To 65
tStop = Timer
tElapsed = tStop - tStart
tHrs = Int(tElapsed / 3600)
tMin = Int((tElapsed - (tHrs * 3600)) / 60)
tSec = Int(tElapsed - (tHrs * 3600) - (tMin * 60))
'-------------------------------------------
Application.Wait (Now + TimeValue("0:00:01"))
'-------------------------------------------
Application.StatusBar = "Please wait  " & Format(tHrs & ":" & tMin &
":" & tSec, "hh:mm:ss")
Next I
Application.StatusBar = "Total Elapsed time: " & tStop - tStart
End Sub

Share: 

 
 
Didn't find what you were looking for? Find more on How to calcualte elapsed time in excel Or get search suggestion and latest updates.


Tagged: