Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Incremental time values based upon clock in and clock out times | Excel Discussion (Misc queries) | |||
How do I calculate time in excel (clock in and clock out | Excel Discussion (Misc queries) | |||
Change EXCEL Clock to Standard Clock or Military Time | Excel Worksheet Functions | |||
Start Clock/Stop Clock | Excel Discussion (Misc queries) |