+ Reply to Thread
Results 1 to 4 of 4

Sorting not working properly

  1. #1
    Registered User
    Join Date
    06-15-2015
    Location
    Waltham, MA
    MS-Off Ver
    Windows 7 Professional
    Posts
    19

    Sorting not working properly

    Hi. I need help troubleshooting this code I've written. I need the code to sort Column J, then sort column CH, then sort column Y. It appears to do this (to some degree, as the little up arrow appears next to the Filter in column J anyway), but not the way I need it to.

    Manually, I would do just as I said above. Sort J ascending, then CH ascending, then Y Oldest to Newest. Here is how I have it written:

    Please Login or Register  to view this content.
    I wonder if it is sorting them all at the same time [somehow]? instead of sort 1, then sort 2, then sort 3.

    Any help in troubleshooting this is really appreciated.

    Thanks!
    E

  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: Sorting not working properly

    The code sorts each column sequentially. If you want the analog of a three-way sort from the UI, reverse the order of the sorts.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-15-2015
    Location
    Waltham, MA
    MS-Off Ver
    Windows 7 Professional
    Posts
    19

    Re: Sorting not working properly

    Not sure I follow what you are saying. sorry, I don't know a ton about VBA, so you'll have to 'dumb it down' for me

    I have a rather large table- columns A - CI. I want the whole table sorted by Column J. Then sorted by Column CH. Then sorted by Column Y.

    The way I have it written- is it sorting the individual column rather than the column within the table?

  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: Sorting not working properly

    Not sure I follow what you are saying. sorry,
    Suppose you select columns A:C and do a three-way sort via Data > Sort, sorting by col A, then B, then C. If you wanted to do the same thing using Autofilter's (sequential) sorting, you would need to sort by col C, then col B, then col A to get the same result. It's just how multi-level sorting works. Try it.

    Have you tried recording a macro that gives you the correct sort order and comparing that to your code?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pivot table not sorting properly
    By Dast in forum Excel Charting & Pivots
    Replies: 13
    Last Post: 06-10-2016, 06:43 PM
  2. Not sorting dates properly
    By lstar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2015, 04:06 PM
  3. [SOLVED] VBA Not Sorting Properly
    By phelbin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2015, 12:56 PM
  4. [SOLVED] IF-THEN-ELSE not working properly
    By danex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-02-2013, 11:15 AM
  5. Sorting A-Z not working properly
    By AKM1 in forum Excel General
    Replies: 1
    Last Post: 09-03-2013, 10:29 AM
  6. Report not sorting properly
    By nzkazza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2012, 10:46 PM
  7. [SOLVED] sorting is not properly done on folders
    By joe41 in forum Word Formatting & General
    Replies: 1
    Last Post: 03-20-2009, 07:40 AM

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