+ Reply to Thread
Results 1 to 5 of 5

Code is very.... slow.... Can it go faster anyhow?

  1. #1
    Registered User
    Join Date
    12-31-2019
    Location
    Apeldoorn, Holland
    MS-Off Ver
    10
    Posts
    6

    Code is very.... slow.... Can it go faster anyhow?

    Hi,
    This code needs to go faster. Does anyone know how?
    Thank!!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Code is very.... slow.... Can it go faster anyhow?

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time. Please read forum rules. Thanks

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Code is very.... slow.... Can it go faster anyhow?

    Hi G,

    Unfortunately the following statement is slow for everyone, just not for you:
    Please Login or Register  to view this content.
    The code will probably run faster if instead of hiding one row at a time:
    a. Make all rows visible
    b. Create a range of rows that will be hidden, and hide the range of rows

    In addition, you probably want to disable and enable Excel Events before and after the code runs:
    Please Login or Register  to view this content.
    You may also want to do the same for ScreenUpdating.

    Lewis

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Code is very.... slow.... Can it go faster anyhow?

    Maybe, just maybe, if you explain in a concise manner what you want to achieve, someone will come up with a code that is not as mixed up (dim statements all over the place comes to mind) and probably will be considerable faster.
    Everybody has their own way of doing things.
    Er zijn vele wegen die naar rome leiden.

    An attachment is always a great help also so people don't have to build a workbook themselves to test their handywork.
    Last edited by jolivanes; 04-01-2020 at 05:44 PM.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code is very.... slow.... Can it go faster anyhow?

    This is where the code is slow. You are looping through each row one cell at a time.

    Please Login or Register  to view this content.
    You do not need to use a loop here.

    1. Enter a formula in an empty column to return a 1 if the row needs to be hidden.

    2. Use Goto Select Special to select all the 1's in your column

    3. Use
    Please Login or Register  to view this content.
    to hide your Rows

    4. Clear the 1's from your column.

    So you can complete the task in about 4 steps.

    If you have 100000 rows then your existing solution takes 500, 000 steps.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

+ 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. Replies: 3
    Last Post: 07-04-2019, 08:34 AM
  2. Slow macro, slow pc or wrong code?
    By corky81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-24-2018, 05:58 AM
  3. Faster if/countif formula for flagging uniques - countif too slow
    By Speshul in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-19-2015, 01:44 PM
  4. [SOLVED] Code using dictionary class is too slow- need it work faster if possible.
    By strud in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 02-04-2014, 12:09 PM
  5. [SOLVED] Running VBA in excel is too slow, how to make it faster?
    By rsbuslon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2013, 05:55 AM
  6. Replies: 2
    Last Post: 01-10-2013, 03:06 PM
  7. Moving a col from one location to another using vba ......really slow.....can faster
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-29-2011, 10:51 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