Now()

viper

Active Member
Joined
Feb 15, 2002
Messages
382
I'm wanting to time my macro. I've tried several things. Can Now() be saved in a variable? I mean, if I put start = Now() at the beginnig of my macro will the time stay in start? Because I also want to put finish = Now() at the end of my macro. If doing so will start and finish end up with the same time? I then want a msgbox to tell me how long the macro took to complete. I've tried a progress bar but that didn't work. So I'm thinking maybe this way.

thanks,
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
one way:

<pre>

Sub timeit()

Range("b1").Value = Now

yourmacro

Range("b2").Value = Now

End Sub


</pre>

Paddy
 
Upvote 0
If you want a message box:


<pre>

Sub timeit()

Dim a As Date
Dim b As Date

a = Now

yourmarco

b = Now

MsgBox Format(b - a, "hh:mm:ss")


End Sub


</pre>


Paddy
 
Upvote 0

Forum statistics

Threads
1,203,350
Messages
6,054,906
Members
444,759
Latest member
TeckTeck

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