+ Reply to Thread
Results 1 to 5 of 5

Sort Macro - Cleaning up code

  1. #1
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Sort Macro - Cleaning up code

    Hi Folks,

    I've searched around and have been unable to find a concise explanation on how to clean up a VBA Sort macro. I was hoping someone might be able to use my code as an example and pare it down, while listing the reasons for why they did so.


    This is a two column sort on a dynamic range.
    The Sub is called from a command button on a user form after user info has been saved.
    This sheet won't be the active sheet when the data is sorted.

    Please Login or Register  to view this content.

    Much appreciated.
    Last edited by max57; 04-25-2010 at 02:20 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Sort Macro - Cleaning up code

    That looks fine. You can do some factoring:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Sort Macro - Cleaning up code

    Thanks Shg,

    This makes more sense.

    Two Quick Questions:
    1. Is it possible to use named ranges for the Sort Range and Key ranges?
    2. Is it possible to use column numbers for the Key Range?

    Thanks

    Mark

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Sort Macro - Cleaning up code

    Sure.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Thumbs up Re: Sort Macro - Cleaning up code

    Thanks shg.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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