+ Reply to Thread
Results 1 to 5 of 5

Macro taking too long to run, macro is to make a summation based on specific criteria.

  1. #1
    Registered User
    Join Date
    04-20-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    51

    Macro taking too long to run, macro is to make a summation based on specific criteria.

    Hello All,

    I am trying to optimize this macro since it is taking way to long to run. It has to go through around 10000 cells and takes about .5 seconds per cell. The whole purpose is to add together cells based on if there is specific text in column A or if it is a specific cell color. Can anyone give me some tips on how to optimize this so it runs much faster.

    Please Login or Register  to view this content.
    Last edited by SAFC; 09-16-2015 at 07:56 AM. Reason: Admin told me to change title.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help Optimize Macro


    Hi !

    Start to desactivate display during execution via ScreenUpdating property, see in VBA inner help …

    Avoid also to use Select, see Destination parameter in Copy VBA help.
    Last edited by Marc L; 09-15-2015 at 05:05 PM.

  3. #3
    Registered User
    Join Date
    09-04-2014
    Location
    WA, USA
    MS-Off Ver
    2007
    Posts
    69

    Re: Help Optimize Macro

    Hi SAFC,

    This is the code that will help your code run faster sometimes by preventing the screen from being updated each time a change is made to a worksheet.
    Please Login or Register  to view this content.
    Sometimes it is necessary to set the ScreenUpdating back to true after your code finishes.

    The most sluggish part of your code is the use of Select and Copy (as Marc pointed out). You should be able to get around this with an alternate code. I'll try and tackle it for you if you are still struggling.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Help Optimize Macro

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem - not what you think the answer might be. (think google search terms?). Once you have done this please send me a PM and I will remove this request. (Also, include a link to your thread - copy from the address bar)

    Many members search our previous posts, and thread titles play a big part of the search. I doubt anybody would do a search based on your title?

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (note: this change is not optional )
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    04-20-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    51

    Re: Help Optimize Macro

    Socrates

    Any help that you can provide would be very grateful. I have added in the screen updating but it is still taking too long.

    The backstory is that this macro will be placed in a lot of different workbooks that have the exact same structure and colored cells but there will be a lot of variation on the number of tabs but will always have the "master" tab. Before doing a distribution, I want to make this macro to take the format of the Master, create a summation tab and then loop through all the cells that are Orange or Yellow [FFCC99 and FFFFF99 respectively] and also for the line labeled "Gross Profit" in column A to add together E:Q, T, V:AG, AI & AK for all rows that have gross profit [Gross Profit is the only type in the file that isn't colored that needs to be added, thinking of changing it to gray [F2F2F2].]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need to optimize the small macro
    By Carnifex930 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-11-2011, 09:00 PM
  2. [SOLVED] Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2005, 03:05 AM
  3. Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2005, 02:05 AM
  4. [SOLVED] Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2005, 01:05 AM
  5. Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2005, 12:05 AM
  6. [SOLVED] Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-05-2005, 11:05 PM
  7. Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-05-2005, 10:05 PM
  8. [SOLVED] Optimize simple macro
    By Biff in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-01-2005, 09:05 PM

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