ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to clock a procedure (https://www.excelbanter.com/excel-programming/325750-how-clock-procedure.html)

42N83W

How to clock a procedure
 
What methods are available with VBA fro clocking procedures? I have a
subroutine that could run anywhere from 30 seconds to over 5 minutes. I'd
like to be able to display the total elapsed time for the procedure to run
in a message box (for my own edification of course, no real "need" for the
information).

Thanks!

-gk-

--
=================================================
The creative act is not the province of remote oracles or rarefied geniuses
but a transparent process that is open to everyone.
-Greg Kot in Wilco Learning How To Die-



Chip Pearson

How to clock a procedure
 
Try something like the following code:

Dim StartTime As Double
Dim EndTime As Double
StartTime = Now
'
' your code here
'
EndTime = Now
MsgBox "Procedure took: " & Format(EndTime - StartTime,
"hh:mm:ss")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"42N83W" wrote in message
...
What methods are available with VBA fro clocking procedures? I
have a subroutine that could run anywhere from 30 seconds to
over 5 minutes. I'd like to be able to display the total
elapsed time for the procedure to run in a message box (for my
own edification of course, no real "need" for the information).

Thanks!

-gk-

--
=================================================
The creative act is not the province of remote oracles or
rarefied geniuses
but a transparent process that is open to everyone.
-Greg Kot in Wilco Learning How To Die-




Bob Phillips[_6_]

How to clock a procedure
 
For a simple solution, take a look at the Timer function in help.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"42N83W" wrote in message
...
What methods are available with VBA fro clocking procedures? I have a
subroutine that could run anywhere from 30 seconds to over 5 minutes. I'd
like to be able to display the total elapsed time for the procedure to run
in a message box (for my own edification of course, no real "need" for the
information).

Thanks!

-gk-

--
=================================================
The creative act is not the province of remote oracles or rarefied

geniuses
but a transparent process that is open to everyone.
-Greg Kot in Wilco Learning How To Die-





Fredrik Wahlgren

How to clock a procedure
 

"42N83W" wrote in message
...
What methods are available with VBA fro clocking procedures? I have a
subroutine that could run anywhere from 30 seconds to over 5 minutes. I'd
like to be able to display the total elapsed time for the procedure to run
in a message box (for my own edification of course, no real "need" for the
information).

Thanks!

-gk-

--
=================================================
The creative act is not the province of remote oracles or rarefied

geniuses
but a transparent process that is open to everyone.
-Greg Kot in Wilco Learning How To Die-



If you need higher resolution, here's an interesting article:
http://www.dicks-blog.com/archives/2...timing-macros/

Best Regards,
Fredrik



Dave Peterson[_5_]

How to clock a procedure
 
Sometimes I sprinkle lines like this to my longer running procedures:

application.statusbar = "Sorting Data Now: " & now

Then I can see the "current" step by just looking at the status bar.

And right before the code finishes, I clean up the statusbar:

application.statusbar = false



42N83W wrote:

What methods are available with VBA fro clocking procedures? I have a
subroutine that could run anywhere from 30 seconds to over 5 minutes. I'd
like to be able to display the total elapsed time for the procedure to run
in a message box (for my own edification of course, no real "need" for the
information).

Thanks!

-gk-

--
=================================================
The creative act is not the province of remote oracles or rarefied geniuses
but a transparent process that is open to everyone.
-Greg Kot in Wilco Learning How To Die-


--

Dave Peterson

Paul Black[_2_]

How to clock a procedure
 
Hi,

I Use this One in a Couple of Programs :-

Dim Start As Double
Start = Timer

'
' Code Here
'

ActiveCell.Offset(3, 0) = "This Program Took " & _
Format(((Timer - Start) / 24 / 60 / 60), "hh:mm:ss") & " To
Process"

Application.ScreenUpdating = True
End Sub

Is this an Acceptable Way of doing this or is Chips Solution Better
Structured.

Thanks in Advance.
All the Best.
Paul



From: Chip Pearson

Try something like the following code:

Dim StartTime As Double
Dim EndTime As Double
StartTime = Now
'
' your code here
'
EndTime = Now
MsgBox "Procedure took: " & Format(EndTime - StartTime,
"hh:mm:ss")




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bob Phillips[_6_]

How to clock a procedure
 
That is what I use to do basic timing on routines where pinpoint accuracy is
not necessary, and is at least the equal of the Now function IMO.

If you want greater accuracy, you need a better timer, such as Karl
Petersens's CCRP Timer http://vb.mvps.org/tools/ccrpTmr/

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Paul Black" wrote in message
...
Hi,

I Use this One in a Couple of Programs :-

Dim Start As Double
Start = Timer

'
' Code Here
'

ActiveCell.Offset(3, 0) = "This Program Took " & _
Format(((Timer - Start) / 24 / 60 / 60), "hh:mm:ss") & " To
Process"

Application.ScreenUpdating = True
End Sub

Is this an Acceptable Way of doing this or is Chips Solution Better
Structured.

Thanks in Advance.
All the Best.
Paul



From: Chip Pearson

Try something like the following code:

Dim StartTime As Double
Dim EndTime As Double
StartTime = Now
'
' your code here
'
EndTime = Now
MsgBox "Procedure took: " & Format(EndTime - StartTime,
"hh:mm:ss")




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com