View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Saucer Man Saucer Man is offline
external usenet poster
 
Posts: 54
Default Getting elapsed time

This isn't working for me. I am using your code in an example which
displays the time in a message box(I don't want it in a cell).

Start = Timer

For Count = 1 To 100000
Sheet1.Cells(1, 1) = "test"
Next Count

Start = (Timer - Start) / (60 * 60)
MsgBox Format(Start, "[hh]:mm:ss")

The msgbox shows :12:44. It should show 4 secs. What is wrong?


"Bernard Liengme" wrote in message
...
If you can forego some precision and work only in second, then use Timer
In the demo below I use Select to make an inefficient macro

Sub tryme()
Start = Timer
For j = 1 To 10000
Cells(j, 1).Select
Next j
Cells(1, 1).Select
Cells(1, 1) = (Timer - Start) / (60 * 60)
Selection.NumberFormat = "[hh]:mm:ss"
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Saucer Man" wrote in message
...
I would like to display the elapsed time a macro takes to run in minutes &
seconds. I only need seconds to be two places. How do I do this?

--
Thanks!