5. VBA Tips - Time Your Code

Nick's picture

How do you time how long it takes for VBA code to run ?


Step1: At the start of your code, create a variable called "Start" (or whatever)

Set it = Timer (that takes a snapshot of the time)


Step2: At the End of your code, you can use a messagebox to display how long it took.

MsgBox Timer - Start & " Seconds"


Download Spreadsheet to see example of how to Time VBA code

Training Video on how to time your code:

Almir's picture

Could you post your code here?

Please post your code here.

NimaIranian's picture

convert to second

i tried your code in my macro and msgbox have shown 36258 seconds

but with a stopwatch i get 1':16" (1 min and 16 sec)!!!

but i could recolonize which one is correct.

pls advise.