Using a drop-down box to sort data based on seperate columns

  • Thread starter Thread starter kevinwaldman9
  • Start date Start date
K

kevinwaldman9

Hello, I'm attempting to implement a drop down box which will allow me to (based on the different choices within the box) sort my lists by different columns.

For example, the criteria I wish to sort by are name, carrier (insurance), coverage type and effective date. I have a drop-down list with these choices, however I wanted to know if there is a way to format these choices to sort the data alphabetically by their respective columns?

This will allow for inexperienced users to quickly filter by the criteria they wish to evaluate.

Thank you
 
Hi Kevin,

Am Fri, 5 Jul 2013 11:39:02 -0700 (PDT) schrieb (e-mail address removed):
Hello, I'm attempting to implement a drop down box which will allow me to (based on the different choices within the box) sort my lists by different columns.

For example, the criteria I wish to sort by are name, carrier (insurance), coverage type and effective date. I have a drop-down list with these choices, however I wanted to know if there is a way to format these choices to sort the data alphabetically by their respective columns?

your table in A:G, your dropdown from data validation in J1 then in code
module of the worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$J$1" Then Exit Sub

Dim Col As Integer

With ActiveSheet
Col = WorksheetFunction.Match(Target, .Range("A1:G1"), 0)
.UsedRange.Sort key1:=.Cells(1, Col), _
order1:=xlAscending, Header:=xlYes
End With
End Sub

Modify to suit

Regards
Claus B.
 
Thank you very much, Claus. This should help a great deal.

Have a good weekend
 
Back
Top