Code to time how long a Macro takes to run...

Frinky

New Member
Joined
Feb 24, 2004
Messages
13
Hey folks,

Does anyone have any code I can stick into the end (plus maybe start) of a macro to display the length of time it took for the macro to run?

I did a quick search of the board but came up with nothing, but if there are any previous posts like this then if you could point me in the right direction it would be great...

Cheers,
f.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Sourdust,

I don't think you meant to send him back to his original posting. In Excel, we call that a "circular reference"!
 
Upvote 0
Drat I tried to edit that before it was spotted but I was too slow as usual. Teach me to try to ignore piles of paperwork and hope they go away :confused:
 
Upvote 0
Sorry, Sourdust. I couldn't pass up the opportunity for a bad Excel joke! :LOL:
 
Upvote 0
hmmm.. I think all excel jokes are bad excel jokes...
So was there a previous post I should look at?
 
Upvote 0
At the beginning of the macro put this

Dim MyTimer as Double

MyTimer = Timer

And at the end of the code put.

MsgBox Timer - MyTimer
 
Upvote 0
I did it this way...

Code:
    Dim dtStartTime As Date
    
    dtStartTime = Now()

    ' Main Macro code...

    MsgBox "Macro ran successfully in " & _
            FormatDateTime(Now() - dtStartTime, 3), vbInformation
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,916
Members
448,533
Latest member
thietbibeboiwasaco

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