Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jon Jon is offline
external usenet poster
 
Posts: 183
Default Time consumption in macros

Hi eveybody, here I am with one question:

How can I know the time which takes to Excel to execute a macro. Because I
have got some loops and I want to know how long does it take in order to view
if I can improve the loops or not.

Probably it is a simple question which I don't know and I think it is very
useful.

Thanks for your time!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Time consumption in macros


At the start of your code put in the line:

start_time = Now


and at the end put:

msgbox "Seconds elapsed: " & int((now-start_time)*86400)


Col


--
colofnature
------------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
View this thread: http://www.excelforum.com/showthread...hreadid=560703

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Time consumption in macros

Jon,

Here's a quick one.

Sub YourSubName()
Dim starttime As Double
starttime = Now
....your code....
MsgBox (Format(Now - starttime, "h:mm:ss"))
End Sub


Mike

"Jon" wrote:

Hi eveybody, here I am with one question:

How can I know the time which takes to Excel to execute a macro. Because I
have got some loops and I want to know how long does it take in order to view
if I can improve the loops or not.

Probably it is a simple question which I don't know and I think it is very
useful.

Thanks for your time!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Time consumption in macros

You want to use the timer something like this...

Dim lng As Long
Dim sngStartTime As Single
Dim sngEndTime As Single

sngStartTime = Timer
For lng = 1 To 1000000000 Step 1
Next lng
sngEndTime = Timer
MsgBox "Duration " & sngEndTime - sngStartTime
--
HTH...

Jim Thomlinson


"Jon" wrote:

Hi eveybody, here I am with one question:

How can I know the time which takes to Excel to execute a macro. Because I
have got some loops and I want to know how long does it take in order to view
if I can improve the loops or not.

Probably it is a simple question which I don't know and I think it is very
useful.

Thanks for your time!!!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Time consumption in macros

As an example, rough and ready but should suit

Dim i As Long, j As Long
Dim nTime As Double

nTime = Timer
For i = 1 To 10000
For j = 1 To 10000
'
Next j
Next i

MsgBox Timer - nTime

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jon" wrote in message
...
Hi eveybody, here I am with one question:

How can I know the time which takes to Excel to execute a macro. Because I
have got some loops and I want to know how long does it take in order to

view
if I can improve the loops or not.

Probably it is a simple question which I don't know and I think it is very
useful.

Thanks for your time!!!





  #6   Report Post  
Posted to microsoft.public.excel.programming
Jon Jon is offline
external usenet poster
 
Posts: 183
Default Time consumption in macros

Really thanks to all of you. It has been very useful.

"Bob Phillips" wrote:

As an example, rough and ready but should suit

Dim i As Long, j As Long
Dim nTime As Double

nTime = Timer
For i = 1 To 10000
For j = 1 To 10000
'
Next j
Next i

MsgBox Timer - nTime

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jon" wrote in message
...
Hi eveybody, here I am with one question:

How can I know the time which takes to Excel to execute a macro. Because I
have got some loops and I want to know how long does it take in order to

view
if I can improve the loops or not.

Probably it is a simple question which I don't know and I think it is very
useful.

Thanks for your time!!!




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
Charting time consumption Espen Rostad[_2_] Excel Discussion (Misc queries) 6 June 17th 09 10:25 AM
What is the formula to calculate electricity consumption TSK Excel Worksheet Functions 4 May 6th 08 01:40 PM
What is the formula to calculate time & power consumption TSK Excel Discussion (Misc queries) 1 May 5th 08 01:42 PM
Fule consumption popunonkok Excel Discussion (Misc queries) 0 April 27th 06 08:16 PM
Consumption function [email protected] Excel Discussion (Misc queries) 6 November 19th 05 12:41 AM


All times are GMT +1. The time now is 12:33 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"