making a drop down to sort data

J

John K

I want to have a drop down that will let me choose either column a, b, c, or
d and then sort a2:d971 on the one I choose.
 
J

joel

You can use the dialog method shown below

Range("a2:d971").Select
Set Sortdialog = Application.Dialogs(xlDialogSort)
With Sortdialog
.Show

End With

End Sub



The dialog has these options

'xlDialogSort orientation, key1, order1, _
'key2, order2, key3, order3, header, custom, case


So you can specify these arguments like this

Range("a2:d971").Select
Set Sortdialog = Application.Dialogs(xlDialogSort)
With Sortdialog
.Show arg1:=xlAscending, arg2:="$A:$A"

End With

End Su
 
Top