Sort Macro - So sort is always the same


Posted by B. Smith on March 21, 2001 12:19 PM

I have a person that asks if we can set the sort box ( Data | Sort | menu box ) to a predefined set up.

They want the sort columns to ALWAYS be SORT BY "Column F" Ascending and then SORT BY "Column B" Ascending, and the "My List Has" to a default to HEADER ROW.

They don't want to re-enter this info everytime. I don't know a way to pre-set this, but was told that the last Excel 'Guru' had set it up before and why don't I know how to do this.

Any Help appreciated...and thanks for listening to me whine a little about my problem.

Brad

Posted by Bob on March 21, 2001 12:41 PM


Brad, probably the easiest way would be to record a macro. First
goto to 'Tools' 'Macro' 'Record New Macro'. Name it "SORT", in the 'Store
Macro in' select 'Personal Macro Workbook' then click OK.


Next click 'Data' 'Sort' then select your criteria.
After it is complete, turn off the Macro Recorder.

Right click on your tool bar, select customize, scroll down to
'Macros' then drag the icon called "CUSTOM BUTTON" to your
tool bar. Click Close...

Next click on the new icon you have on your tool bar.
This will allow you to assign a macro to your icon, click
on 'Personal.XLS' then select 'Personal.xls!Sort'

Now every time you click that icon it will sort the same
way you recorded it.

The VBA should look something like this....

Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("F2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom

Tx..Bj



Posted by Brad Smith on March 26, 2001 12:48 PM

Re: Sort Macro - Thanks....It works Great

A big thanks to BOB.

I just installed the macro and custom button on the persons computer and got a HUGE thank you. So, I am passing it on.

THANKS for the help!

Brad