Time the running time of a procedure

DougStroud

Well-known Member
Joined
Aug 16, 2005
Messages
2,968
How could I add a timer to check the running time.
One approach given to me was this:
In the beginning of my code>>>>

mTimer = Timer

at the end of my code>>>>

MsgBox Time - mTimer

At the end of my procedure the MsgBox showed 11:13:55pm
So it showed what appears to me the finish time, not the elapsed time.

thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
That works.
But I may have another problem w/ my approach-
The above method works on anything small- .5 to 15 seconds.
I have a procedure I want to time that takes 3-5 minutes to run, the msgbox returns a value of 0.00 no matter what format every single time I run it, upon completion of the procedure.
I have dimmed mTimer as a Single or Double in case it needed more space but that did nothing different.
This calls a number of Subs to run, would this have anything to do w/ it?
 
Upvote 0
Linked back from http://www.mrexcel.com/board2/viewtopic.php?t=285498

Doug

Try this

Code:
Sub Timer()
Dim StartTime As Variant, StopTime As Variant, Elapsed As Variant
StartTime = Time
'
'The code that you want to time goes here
'
StopTime = Time
Elapsed = StopTime - StartTime
MsgBox "Time elapsed:" & Chr(13) & Format(Elapsed, "hh:mm:ss")
End Sub
 
Upvote 0
Roy,
I was looking this through- have downloaded it and will install and see how it goes. Vog got me squared away w/ what I needed currently. But that tools looks like it will come in real handy.
I will post back later after I get it working- I do have some macros that i want to test/compare for time-

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top