PDA

View Full Version : Show running time of macro



sujittalukde
05-28-2008, 03:06 AM
I am using a for next loop to run a macro. I want to show on the statussbar the time of running the same in hh:mm:ss format. Whats the code will be? code is like this:


For i = 1 to 100000
'code is herre
next i

Bob Phillips
05-28-2008, 03:26 AM
Dim nTime As Double
Dim i As Long, j As Long
Dim tmp

nTime = Timer
For i = 1 To 100000

For j = 1 To 1000

tmp = i * j
Next j
Next i
MsgBox "Time taken was " & Timer - nTime & " seconds"

sujittalukde
05-28-2008, 03:46 AM
Thanks xld for the code but in my code inbetween for next loop the code is opening closed WB, pulling data, inserting rows, copying sheets to new WB and also saving the new WB to a folder. Now when I am incorporating this code, the code is looping to "j" only for a long long time and I have to terminate the code running.
Actually I want to to display the running time only Is there any Timer control in VBa as in VB. I tried to search but not found any such Timer control.? Any hints...

Bob Phillips
05-28-2008, 03:49 AM
How about a progressbar?

sujittalukde
05-28-2008, 04:21 AM
I am already using progress bar but wishing to replace with timer, if possible.