+ Reply to Thread
Results 1 to 3 of 3

Macro for Sorting

  1. #1
    Registered User
    Join Date
    04-21-2009
    Location
    East Peoria, IL, USA
    MS-Off Ver
    Excel 2013
    Posts
    39

    Macro for Sorting

    I have created a spreadsheet with a few command buttons to sort the data. One of the gentlemen that will be reviewing this sheet can never remember how to sort correctly, so spreadsheets often get scrambled after he gets a hold of it. Anyway, I used the macro recorder to create the code, but I don't know how to let him sort ascending / descending. I added a couple of radio buttons for him to select, then click the button of the appropriate column. Can anyone help with the code to make it function depending on which radio button is selected. Thanks.
    Attached Files Attached Files
    Last edited by BrettW; 09-13-2010 at 03:56 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Macro for Sorting

    Hello BrettW,

    In Module1 I have added a Public Variable Direction. This is used in the Sort method to replace the xlAscending and xlDescending values. Ascending is the default whenever the workbook opens. Here is the Data worksheet controls code...

    Data Worksheet Controls Code
    Please Login or Register  to view this content.

    Module1 Code
    Please Login or Register  to view this content.

    ThisWorkbook Event Code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-21-2009
    Location
    East Peoria, IL, USA
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Macro for Sorting

    Thanks Leith, it works great.

+ 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