View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default toggle sort columns

Hi,

This test g3 and G4 to see which way they are sorted and then does the cort
in the opposite direction.

Sub sort_date()
If Left(Range("G3"), 1) Left(Range("G4"), 1) Then
MyWay = xlAscending
Else
MyWay = xlDescending
End If
Range("A3:T23").Sort Key1:=Range("G3"), _
Order1:=MyWay, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Mike

"JSnow" wrote:

I have a button linked to a macro that will sort a data ascending. Is there
a way to click said button a second time and it will sord descending? Here's
the code thus far:

Sub sort_date()
Range("A3:T23").Sort Key1:=Range("G3"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub