+ Reply to Thread
Results 1 to 6 of 6

Speed up VBA Sub

  1. #1
    Registered User
    Join Date
    01-19-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Speed up VBA Sub

    I've got some VBA Subs I use to frequently fix millions of rows of excel data. They all work very well and are very fast and the same speed to the ***** eye. However, one of the Subs (badSub) processes MUCH slower than the others. How can I change "badSub" to be as fast as the "GoodSubs". I'm not interested in code like that I could apply to all the Subs like:

    Please Login or Register  to view this content.
    I'm interested in what part of the "badSub" code is causing it to behave much slower than the others.


    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,321

    Re: Speed up VBA Sub

    Hi Shawn and welcome to the forum,

    When you "Select" things it slows the process down.

    Instead of:
    Please Login or Register  to view this content.
    Try

    Please Login or Register  to view this content.
    Let us know if this is any faster or not...
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Speed up VBA Sub

    Hi ShawnWeber,

    A quick look shows that the set RangeFound in badsub is inside the loop whereas it is outside the loop in the three example goodsubs, don't know if that will make a difference or not and I didnt try to fully understand the code so maybe for logical reasons it needs to be in the loop.

    is the amount of rows to be deleted the same in each instance?

    just a couple of observations
    Jmac

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Speed up VBA Sub

    Hi ShawnWeber,

    A quick look shows that the set RangeFound in badsub is inside the loop whereas it is outside the loop in the three example goodsubs, don't know if that will make a difference or not and I didnt try to fully understand the code so maybe for logical reasons it needs to be in the loop.

    is the amount of rows to be deleted the same in each instance?

    just a couple of observations
    Jmac

  5. #5
    Registered User
    Join Date
    01-19-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Speed up VBA Sub

    @ MarvinP all four subs use .select and the three goodSubs run very fast

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Speed up VBA Sub

    This line would be slow

    Please Login or Register  to view this content.
    I am not even sure it works. The loop might be infinite.
    Imagine you have selected the entire column and the code check for each line of the column.

+ 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. VBA speed up
    By bensonsearch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2011, 02:46 AM
  2. VBA Speed up
    By sparx in forum Excel General
    Replies: 2
    Last Post: 04-29-2006, 11:59 AM
  3. [SOLVED] How to speed up VBA?
    By Cactus in forum Excel General
    Replies: 3
    Last Post: 06-14-2005, 11:05 AM
  4. Speed me up please with VBA
    By cdjsb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2005, 11:34 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