+ Reply to Thread
Results 1 to 4 of 4

Speeding up a macro

  1. #1
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Speeding up a macro

    I recorded and then modified a macro. It seems fairly easy but it takes like 20 or 30 minutes to run. It puts a formula in columns, autofills the columns and then copies, paste special values them all. I am wondering if there is a way to make it run faster. There are many columns with formulas that go through the process so i have to wonder if it's just too big and unavoidable.

    I also don't really understand the process. In File - Options, Enable Multi Threaded Calculations and Use All Processors (4) is checked. Enable Iterative Calculation is unchecked and I have no idea what that means.

    As the macro runs it shows that all processors are being used and works its way from 0% to 100%. It repeats the 0-100% part multiple times. I don't understand that. Why not just once? Why does it restart the calculations multiple times?

    I am attaching the code in a workbook. It has no data or anything - just the code. Is it possible for anyone to look at the code and maybe suggest a way to make it run faster? If necessary I can attach a complete sample so the code can be run but I don't know if it's necessary.

    Anything anyone can suggest to make it faster would be so, so appreciated by me.
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Speeding up a macro

    One quick suggestion:

    You very rarely ever have to select an object to work with it...

    http://www.tushar-mehta.com/excel/vb...rder/index.htm

    Example:
    Please Login or Register  to view this content.
    Becomes:
    Please Login or Register  to view this content.
    You can also research...

    https://www.soa.org/News-and-Publica...s42-roper.aspx

    or

    https://www.techrepublic.com/blog/mi...-excel-macros/

    or

    http://datapigtechnologies.com/blog/...xcel-vba-code/


    Also, it might be easier to get help if you post a small sample workbook with the code in the VBE.
    Last edited by jeffreybrown; 02-01-2018 at 09:56 PM.
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    02-26-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    248

    Re: Speeding up a macro

    Hi, Jeff

    Thank you. I will make your Select change and check out the links you provided. I also just noticed that the range for the formula doesn't match the corresponding range for the autofill. I added a column a day or two ago. Fixed formulas, not autofill ranges. Although even before I messed that part up and it was running properly, it took forever. I will however fix the ranges, make your change and see what happens. And I'll check out your links. This Excel beast is such a struggle... But thoroughly enjoyable and addictive. The challenge... The conquer... But, oh so many pieces in the puzzle... Sigh. Let's see if I'm back here tomorrow night with a sample workbook. lol. Thanks again.

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Speeding up a macro

    Here's the code with all the Selects removed. Other changes are Highlighted in RED. I was unable to test it due to presence of un-available User Defined Functions and Named Ranges:
    Please Login or Register  to view this content.
    Note that I substituted Values for Formulas directly (no copy/paste), and did so BEFORE inserting the column (which will force a recalculation.)
    Last edited by leelnich; 02-02-2018 at 12:44 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

+ 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. [SOLVED] Need Help Speeding up my Macro.
    By disepyon in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-07-2017, 03:22 PM
  2. [SOLVED] Speeding up Macro
    By booney440 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-09-2017, 10:41 PM
  3. Help speeding up a Macro
    By jbrooks1988 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-12-2016, 12:57 PM
  4. [SOLVED] Speeding Up Macro
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-03-2015, 11:15 AM
  5. [SOLVED] Speeding up my macro
    By jsuarez199 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-03-2013, 10:52 AM
  6. [SOLVED] Help in speeding up my macro!
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2013, 12:04 PM
  7. Speeding up a macro
    By Mister P in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-20-2010, 02:50 AM

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