ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   making a drop down to sort data (https://www.excelbanter.com/excel-programming/437997-making-drop-down-sort-data.html)

John K

making a drop down to sort data
 
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.

joel[_480_]

making a drop down to sort data
 

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 Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=166926

Microsoft Office Help



All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com