+ Reply to Thread
Results 1 to 5 of 5

Improve speed of Sort!

  1. #1
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Improve speed of Sort!

    Hi, I just learned to do the copy and paste the fast way and my macros are thanking me for it.

    Is their a way to improve the speed of a Sort?

    Please Login or Register  to view this content.

    This Sort is done thousands of times in a loop so any speed change is noticeable!


    Any help is appreciated! Thanks.
    Last edited by stockgoblin42; 04-29-2013 at 01:05 PM.

  2. #2
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Improve speed of Sort!

    How about:

    Please Login or Register  to view this content.
    Is that the fastest way?

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Improve speed of Sort!

    Yes, using the Range.Sort method is faster than the Worksheets.sort method. But why are you sorting thousands of times in a loop? Wouldn't it be easier to just sort once after everything else is done?
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Re: Improve speed of Sort!

    Oh, I'm checking multiple combinations of lines in a list with some of them being constant. All lines have to be put in order of slope for the condition formulae to work.

    Here's my macro I'm trying to speed up.

    Can you see anything else I can change to make it faster?

    Please Login or Register  to view this content.
    Last edited by stockgoblin42; 04-29-2013 at 02:54 PM.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Improve speed of Sort!

    You can get rid of the select statements. I also see you have application.calculation and application.screenupdating being updated during the loops instead of outside of the loops. You could set the sheets equal to variables instead of having the code define the sheet each time. But without knowing what your start looks like and what your desired end looks like, there's not much more advice I can offer. I also can't figure out why you need so many for loops. It seems incredibly inefficient.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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