+ Reply to Thread
Results 1 to 6 of 6

Need Help with creating a Sorting Macro

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Salem, MA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Need Help with creating a Sorting Macro

    I want to use a macro to sort when the number of selected rows change. Here is my code for sorting. How do I change it so it will work only on the rows I select? So for example, in my code below I selected A9:D17 but this changes throughout the worksheet in sections that need sorting. Is this possible to do with a macro? Thanks.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    09-22-2012
    Location
    Berkeley, CA
    MS-Off Ver
    Excel 2010
    Posts
    112

    Re: Need Help with creating a Sorting Macro

    Can you attach a workbook?
    ------------------------
    W2

  3. #3
    Registered User
    Join Date
    02-11-2013
    Location
    Salem, MA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Need Help with creating a Sorting Macro

    I have tried to attach a sample workbook. Basically my workbook is a summary of names and codes per all US states, sorting by Columns D,C,B. But since there is a space in my worksheet between every state, I need to highlight each section and pick my sorting columns every time. I want to create a macro to shorten the process by not having to sort each section every time. Each section has a different amount of rows and values every month. Thanks.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Need Help with creating a Sorting Macro

    Try
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-22-2012
    Location
    Berkeley, CA
    MS-Off Ver
    Excel 2010
    Posts
    112

    Re: Need Help with creating a Sorting Macro

    Try this:

    Please Login or Register  to view this content.
    As long as only one of the cells in the region you want to sort is selected the macro will sort that region based on the D, C, and B columns. If more than one cell is selected an error will throw. There must be a blank row between sections for the macro to sort each section independently. In addition. there needs to be a blank row between the header row and the first row of data.

    HTH

  6. #6
    Registered User
    Join Date
    02-11-2013
    Location
    Salem, MA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Need Help with creating a Sorting Macro

    SOLVED: Thank you "Cofad". That works and saves me a lot of time. Thank you so much.

+ 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