ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting how long a Macro takes to run (https://www.excelbanter.com/excel-programming/322573-counting-how-long-macro-takes-run.html)

Diane Alsing

Counting how long a Macro takes to run
 
I have a Macro that Opens, saves & closes a directory of files (to
automatically update data links, etc). I would like to add a little piece of
code that takes note of the time the Marco Starts & Stops & displays the time
it took to run when it is completed.

I currently have code that displays the quantity of files updated.

MsgBox "Update Complete. " & Counter & " Files Updated"

I was wondering if it was possible to perhaps capture the before & after
times & just subtract them (but I know dates/times in Excel are weird so I'm
not sure how to do it)

Thank you.
Regards,
Diane

Tom Ogilvy

Counting how long a Macro takes to run
 
dim sngStart as Single

sngStart = Now
- your code

MsgBox "Update Complete. " & Counter & _
" Files Updated" & VBNewline &
" took " & format(now - sngStart,"hh:mm:ss")

--
Regards,
Tom Ogilvy


"Diane Alsing" wrote in message
...
I have a Macro that Opens, saves & closes a directory of files (to
automatically update data links, etc). I would like to add a little piece

of
code that takes note of the time the Marco Starts & Stops & displays the

time
it took to run when it is completed.

I currently have code that displays the quantity of files updated.

MsgBox "Update Complete. " & Counter & " Files Updated"

I was wondering if it was possible to perhaps capture the before & after
times & just subtract them (but I know dates/times in Excel are weird so

I'm
not sure how to do it)

Thank you.
Regards,
Diane




Diane Alsing

Counting how long a Macro takes to run
 
As always - fantastic! Thanks.

"Tom Ogilvy" wrote:

dim sngStart as Single

sngStart = Now
- your code

MsgBox "Update Complete. " & Counter & _
" Files Updated" & VBNewline &
" took " & format(now - sngStart,"hh:mm:ss")

--
Regards,
Tom Ogilvy


"Diane Alsing" wrote in message
...
I have a Macro that Opens, saves & closes a directory of files (to
automatically update data links, etc). I would like to add a little piece

of
code that takes note of the time the Marco Starts & Stops & displays the

time
it took to run when it is completed.

I currently have code that displays the quantity of files updated.

MsgBox "Update Complete. " & Counter & " Files Updated"

I was wondering if it was possible to perhaps capture the before & after
times & just subtract them (but I know dates/times in Excel are weird so

I'm
not sure how to do it)

Thank you.
Regards,
Diane






All times are GMT +1. The time now is 01:14 PM.

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