Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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-


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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-



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default 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!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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-






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incremental time values based upon clock in and clock out times saltnsnails Excel Discussion (Misc queries) 8 January 13th 09 08:11 PM
How do I calculate time in excel (clock in and clock out chad Excel Discussion (Misc queries) 3 January 7th 08 10:09 PM
Change EXCEL Clock to Standard Clock or Military Time YoMarie Excel Worksheet Functions 4 April 29th 07 08:39 PM
Start Clock/Stop Clock abfabrob Excel Discussion (Misc queries) 9 June 28th 05 04:26 PM


All times are GMT +1. The time now is 02:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"