View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default How do I alternate a sort from a text box via macros?

Here's a down and dirty method

Dim x As Long, ordr As Long

x = MsgBox("Sort Ascending (Yes), Descending (No)", vbYesNo)

If x = 6 Then ' 6 = Yes
ordr = 1 ' 1 = ascending
Else
ordr = 2 ' 2 = descending
End If

Range("E:E").Sort Key1:=Range("E1"), Order1:=ordr, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


--
steveB

Remove "AYN" from email to respond
"g.a." wrote in message
...
I have a column of data that I am using a text box to run a macro that
sorts
the data in descending order. How can I alternate the sort criteria
(ascending/descending) using the same text box? Push once - sort in
ascending order; push again - sort in descending order. Thanks.