Results 1 to 5 of 5

Thread: Excel Auto Filter unsorted my VBA sort?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    11

    Excel Auto Filter unsorted my VBA sort?

    I have a snipet of code that performs a sort for me:

    Columns("A:AD").Select
    Selection.Sort Key1:=Range("AD2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    The sort works fine. The person I will be sending this to loves his auto filters, and he will try to use them. The problem is whenever I try and select something from an autofilter, excel undoes my sort. If I sort the data by hand, without using VBA, the sort remains intact. This is most frustrating, any insight? Thanks!

  2. #2
    Member
    Join Date
    Jul 2006
    Posts
    41

    Re: Excel Auto Filter unsorted my VBA sort?

    The problem is whenever I try and select something from an autofilter, excel undoes my sort.
    What do you mean by "select something?" As in Cells(3,2).Select or clicking on a cell or what?

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    11

    Re: Excel Auto Filter unsorted my VBA sort?

    Im not sure if im explaining this well enough, but here goes:
    I enable the autofilter (data menu, filter -> auto filter)
    I then choose one of the drop down menus from the auto filter and make a selection. Regardless of what I select, it undoes my sort.

  4. #4
    Member
    Join Date
    Jul 2006
    Posts
    41

    Re: Excel Auto Filter unsorted my VBA sort?

    I tried to recreate your problem but I can't. Maybe post all of the code or more of it so we can see what you're doing; and make sure you surround it by vbcode tags. check here for reference: http://www.vbforums.com/misc.php?do=bbcode#code

    Does your code create an autofilter and then sort, or does it just sort and your user creates the autofilter?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    11

    Re: Excel Auto Filter unsorted my VBA sort?

    The code does not create the autofilter, I put it in afterwards.
    For whatever reason, it is not doing it today. It must have been some kind of abnormality in yesterday's data that caused this (as the data for this project changes daily). This is most likely why it couldn't be recreated. I'll update this if it returns and I can nail it down.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width