+ Reply to Thread
Results 1 to 4 of 4

Need to sort by more than 3 columns

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2008
    Location
    Michigan
    Posts
    2

    Need to sort by more than 3 columns

    The Data/Sort tool only allows a 3-level sort. I need to do an 8-level sort. The best way I can think of to do this is to sort by the first 3 columns, then tell the macro to select only the rows that met all those first three criteria (for example, all Mercury Sables from 2006), then sort that group of cells by the next three columns, and so on.

    This is the pseudocode I brainstormed.

    select all data
    sort first 3 levels
    insert column for markers before 3rd-sort-level column
    create markers
    use markers to select the inclusive rows
    sort next 3 deeper levels
    insert column for markers before 6th-sort-level column
    create markers
    use markers to select the inclusive rows
    sort final 2 levels

    I don't know what VB commands to use to do it. Please help. Thanks!

  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
    Hello Bridge_To_Terabithia,

    I would use the Auto Filter option under the Data menu. If row is contains the column headers, select the entire row. On the main menu go to Data > Filter > AutoFilter. This will place a drop down arrow in column header. Start with the first column and select the information you want to see. Repeat the process for all 8 columns.

    Sincerely,
    Leith Ross

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    I agree with Leith's suggestion to use AutoFilter. Just remember to sort sequentially from the least significant column to the most. This will give the same result as if you did a single 8-way sort.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    11-07-2008
    Location
    Michigan
    Posts
    2
    Unfortunately, autofilter won't do the job, nor will the pivot-table that came with the data; what I really need is to literally rearrange the order of all the rows, so that the whole list is displayed the way I described.

    What I'm really in need of is just some elementary VB commands to:
    - execute Data Sort according to known criteria
    - recognize when the cell value changes as I go down the column
    - set and recognize markers (or variable values) when the change in cell value is sensed
    - use the markers to select the specific rows I want to sort next

    Any help is much appreciated.

+ 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