+ Reply to Thread
Results 1 to 8 of 8

Time Formula, time it takes to calculate

  1. #1
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Time Formula, time it takes to calculate

    Hello,

    What I'd like to do is to time how long it takes for a formula to finish calculation. I'd like to do this to compare different calculations between Sumproduct vs countif vs sumif etc.

    I have found this link

    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx


    where there's a vba code for measuring calculation time but I cannot get it to work under Excel 2010/64-bit.

    Is anybody aware how to get this to work?

    Thank you

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Time Formula, time it takes to calculate

    If you mean the VBA code with the API Declare statements, they are written for a 32 bit system. You need to convert to run on a 64 bit system...

    http://www.jkp-ads.com/articles/apideclarations.asp

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Time Formula, time it takes to calculate

    Why not just add
    Range("A1") = Time

    as the first line of your test process, and conclude it with

    Range("A2") = Time

    Then the difference between the two is the time the process took.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Time Formula, time it takes to calculate

    Thank you both for the replies.

    I would prefer a vba approach as I could set up a shortcut key which will ultimately be much faster/easier to test.

    cytop, I understand that I need to replace the Declare Statements but unfortunately all looks very confusing on how to do it and what to replace exactly. Would it be possible get some extra help on this?

    Thank you

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Time Formula, time it takes to calculate

    Basically, the declarations change from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Any Long types in the declaration may, or may not, change to LongPtr type. Whether they change is determined by what they represent; Function arguments or return values that represent addresses in memory change. This is because a 64-bit Operating System has a memory space that is too large to hold in a Long data type. Arguments or return values that represent data will still be declared Long even in 64-bit.

    A good example is the SendMessage API

    32 Bit
    Please Login or Register  to view this content.
    64 bit
    Please Login or Register  to view this content.
    The hWnd parameter and Return Value change as they are memory addresses whereas the remaining Longs are data...

  6. #6
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Time Formula, time it takes to calculate

    Thank you for the explanation cytop. Just got it to work, only a couple of lines actually needed replacing.

    For convenience, in case anyone will find this useful, here's the macro that will work under excel 64-bit

    Please Login or Register  to view this content.

    Thank you both for the help!
    Last edited by sans; 03-20-2013 at 07:44 AM.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Time Formula, time it takes to calculate

    Quote Originally Posted by sans View Post
    Thank you both for the replies.

    I would prefer a vba approach as I could set up a shortcut key which will ultimately be much faster/easier to test.
    The suggestion I gave you was VBA syntax

  8. #8
    Registered User
    Join Date
    02-16-2023
    Location
    UK
    MS-Off Ver
    2010
    Posts
    1

    Re: Time Formula, time it takes to calculate

    Quote Originally Posted by sans View Post
    Thank you for the explanation cytop. Just got it to work, only a couple of lines actually needed replacing.

    For convenience, in case anyone will find this useful, here's the macro that will work under excel 64-bit...
    If you ever read this... thank you

+ 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