• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sort a vba generated unique filter

Gandalf

Member
Hello All

I hope someone may be able to help me. I can generate 2 lists of unique data from 2 columns that I then use in list boxes on another sheet using the code below
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

  ActiveSheet.Range("C2:C311").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ActiveSheet.Range("K2"), Unique:=True

   
  ActiveSheet.Range("F2:F311").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("L2"), Unique:=True

End Sub

Is it possible to add something to this to automatically sort the data?

Many thanks in advance for any help.

Gandalf
 
Sort each range, or sort block of range? You can certainly do it. I'd suggest recording a macro of you sorting the data (either col K, J, or K & J) to see how to do it. Don't need to worry about exact data length, as blank will be at end, so you could do something like
Code:
Range("k2:K1000").Sort Key1:=Range("K2"), order1:=xlAscending, Header:=xlNo
 
Back
Top