+ Reply to Thread
Results 1 to 8 of 8

How To Speed up macro

  1. #1
    Registered User
    Join Date
    02-28-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    14

    How To Speed up macro

    Hi Guys!

    I've created a vba macro that formates the excel sheets in some defined format.
    It runs quite smoothly. But then as soon as I shift the focus to some other application
    the performance drastically reduces. Normal run time of 30 minutes is extended to over
    2 hours. The application is quite optimized so no need to discuss about "application.screenUpdating"
    and all. Please help me getting over this issue.
    The problem can be of "thread priorities" (just a guess).

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: How To Speed up macro

    We probably can't help much without seeing your code, I'm afraid. Even a 30 minute run-time to do some formatting sounds excessive. What are you doing?

  3. #3
    Registered User
    Join Date
    02-28-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: How To Speed up macro

    I don't need any syntax modification that's why I didn't posted the code.
    Also may be you did not get the problem, It is related to thread priority concepts
    rather than code modification that can be solved by changing syntax.

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: How To Speed up macro

    If it's a thread priority issue then it's a Windows question.

    However, as per the big banner at the top of the screen, this is an Excel forum, and as an Excel developer I'd say that if your code takes 30 minutes to run, even when it has priority, it's probably not optimised.

    If you're happy that it's as efficient as it possibly can be then great. Good luck with that.

  5. #5
    Registered User
    Join Date
    02-28-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: How To Speed up macro

    Here I'm dealing with around 50 worksheets each having around 2000 lines
    each needs different merging and borders. Its kind of a menu tree. I can't post
    the code because of the restrictions otherwise I would already have.
    Now you can understand why it is taking 30 minutes to run speed is around 12 to 15 lines per second.
    I hope that is not bad the problem occurs only when the excel looses focus and you are somewhat
    right that its a windows problem. But i needed to bypass that in excel.

  6. #6
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: How To Speed up macro

    Have you read this thread on another site? One of the responses suggests opening Excel from a .cmd file that places Excel at the highest priority.

    http://superuser.com/questions/6400/...-does-not-have

    And this thread discusses giving the application high priority in real time.
    http://www.mrexcel.com/forum/showthread.php?t=438142

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How To Speed up macro

    And instead of opening a file you'd better use 'getobject'.

    It's rather weird you won't show your code when your thread title is about 'speeding up your macro'.
    I hope you realise that code & macro are identical ?
    Last edited by snb; 04-13-2012 at 03:57 PM.



  8. #8
    Registered User
    Join Date
    02-28-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: How To Speed up macro

    thnx Whizbang got exactly what i wanted

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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