Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've got a range called "Data" and a column called "City" and a button
called SortCity on top of that column. I've recorded a macro that sorts the column (ASCENDING). How do I adjust the code so that alternate clicks on the button sort ASCENDING then DESCENDING, etc. My code thus far: Sub SortCity() ' SortCity Macro ' Macro recorded 11/12/2004 by pcross Application.Goto Reference:="Data" Selection.Sort Key1:=Range("G4"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub I tried If / Then logic with a variable (eg assign it 1, then 0, etc.) and also tried If / Then logic by comparing the first cell with the last (and ASC sort if it's less than, etc) but in both cases the sort order didn't change. Thanks for help, Paul Cross |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code for variable sort order | Excel Discussion (Misc queries) | |||
Retaining Sort order in the Sort Dialog box | Excel Discussion (Misc queries) | |||
Sort sheet based on particuilar sort order | Excel Worksheet Functions | |||
sort last name order | Excel Discussion (Misc queries) | |||
sort order | Excel Discussion (Misc queries) |