+ Reply to Thread
Results 1 to 4 of 4

VBA Code for displaying time taken by a macro

  1. #1
    Macro man
    Guest

    VBA Code for displaying time taken by a macro

    hi,

    can you pls give me the VBA Code for diplaying the time taken by a
    macro to give the output.

    Regards,

    Karthik


  2. #2
    JE McGimpsey
    Guest

    Re: VBA Code for displaying time taken by a macro

    One way:

    Dim time1 As Double, time2 As Double
    time1 = Timer
    ' <your macro here>
    time2 = Timer
    MsgBox Format(time2 - time1, "0.00 \s\ec")

    In article <[email protected]>,
    "Macro man" <[email protected]> wrote:

    > hi,
    >
    > can you pls give me the VBA Code for diplaying the time taken by a
    > macro to give the output.
    >
    > Regards,
    >
    > Karthik


  3. #3
    Bob Phillips
    Guest

    Re: VBA Code for displaying time taken by a macro

    Depends upon how accurate you want it. If you want it to get an idea of the
    performance of one piece of code over another then a very simple method is
    to set a timer at the start and then check against it at the end

    Dim nTime

    Timer = nTime

    .... your code

    Debug.Print Timer - nTime

    run the code a number of times and average teh results.

    If you need more accuracy, search for Hi-Res Timer in the excel newsgroups
    in Google, http://tinyurl.com/a4dov

    --

    HTH

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


    "Macro man" <[email protected]> wrote in message
    news:[email protected]...
    > hi,
    >
    > can you pls give me the VBA Code for diplaying the time taken by a
    > macro to give the output.
    >
    > Regards,
    >
    > Karthik
    >




  4. #4
    Bob Phillips
    Guest

    Re: VBA Code for displaying time taken by a macro

    Type, should be

    nTime = Timer

    at start

    --

    HTH

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


    "Bob Phillips" <[email protected]> wrote in message
    news:emK%[email protected]...
    > Depends upon how accurate you want it. If you want it to get an idea of

    the
    > performance of one piece of code over another then a very simple method is
    > to set a timer at the start and then check against it at the end
    >
    > Dim nTime
    >
    > Timer = nTime
    >
    > .... your code
    >
    > Debug.Print Timer - nTime
    >
    > run the code a number of times and average teh results.
    >
    > If you need more accuracy, search for Hi-Res Timer in the excel newsgroups
    > in Google, http://tinyurl.com/a4dov
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Macro man" <[email protected]> wrote in message
    > news:[email protected]...
    > > hi,
    > >
    > > can you pls give me the VBA Code for diplaying the time taken by a
    > > macro to give the output.
    > >
    > > Regards,
    > >
    > > Karthik
    > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1