+ Reply to Thread
Results 1 to 17 of 17

Macro takes approx. 15 seconds to run, how do i reduce run time?

  1. #1
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Macro takes approx. 15 seconds to run, how do i reduce run time?

    Good morning happy campers,

    I have a large sheet with numerous formula's etc within it, spread over 4 tabs, with a 5th tab readin info from an exported source.

    I have the following macro,
    Please Login or Register  to view this content.
    Now i know its a big ask, asking for help on a code/sheet without loading the sheet here, but at present its A) Huge and B) full of sensitive info, so the next big ask would be if someone would kindly do this with receiving the sheet through drop box perhaps?

    I look forward to your responses, thanks in advance.

    Galvinpaddy

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    have you at least stepped through the code to figure out which parts take the most time?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Contributor
    Join Date
    02-24-2011
    Location
    Belfast, N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    Galvinpaddy,

    Good luck, I have a macro which takes 3min 40sec to run although admittedly it is much longer LOL

  4. #4
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    Quote Originally Posted by JosephP View Post
    have you at least stepped through the code to figure out which parts take the most time?
    Hi JosephP, i have gone through 'Step Into' using F8 from the Visual Basic window, but there is no delay.
    Once i have gone back to the sheet, in the bottom right it did read 'Calculating' with an incremental percentage.

    Other than this i am afreaid i am slightly lost.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645
    Do you need to calculate?
    If posting code please use code tags, see here.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    then I reckon it's the recalculation that causes the delay and not your code. you need to look at your formulas if 15 seconds is really unacceptable

  7. #7
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    Hi both,

    Calculations - Do i need to? hhmm, i believe i do, as all cells within one tab are all linked to the exported data (another excel sheet in a seperate location) if i take off the
    Please Login or Register  to view this content.
    Would that have a negative impact on the rest of the code?

  8. #8
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    OK, update, and before i do, i have no idea why it works this way

    Once i run the macro, the sheet will basically appear to hang as if the code is taking ages, but as soon as i click somewhere on the sheet, the formula completes.

    Is there something dodgy in my original code??

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    no-that's normal excel behavior. if you click and wait a moment excel will probably start calculating again

  10. #10
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    but thats the thing, it doesnt appear to do so. once i click, it works as normal and lets me carry on with what im doing.
    Is it simply the case that i cant resolve it and as such need to click to continue?

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    it shouldn't be-do you have calculation set to manual?

  12. #12
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    No, its set to Auto

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    then why do you explicitly calculate the range in your code?

  14. #14
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    in all fairness, i have no idea.
    The code was created by visiting here and asking various questions, in all fairness, i understand some, but not all of it.
    Please, feel free to pull it to pieces and re-order it

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    try just commenting out the
    Please Login or Register  to view this content.
    line

  16. #16
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    Ok, i have commented out that line and have come across the following:

    When i add a 'button (form control) with the macro above added to it, the code takes around 1 minute to cycle
    When i add a 'Command Button (Active X Control) with the above macro, the code will run in about 2-4 seconds,

    With the Form Control, i am unable to click somewhere to continue using the sheet until it un freezes
    With the Command Button, as soon as i click it, i can click in a cell and the macro appears to be complete.

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro takes approx. 15 seconds to run, how do i reduce run time?

    "appears to be complete"-have you checked it is actually doing what you think?

+ 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