View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default How to leave Selection.Sort Key open....



This works for me, always sorting based on the last row of data:

Sub Macro99B()
Dim myC As Range

Set myC = Range("C65536").End(xlUp)
myC.CurrentRegion.Sort _
Key1:=myC, _
Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub


--
HTH,
Bernie
MS Excel MVP


"J.W. Aldridge" wrote in message
...

Added the search code, but still......

Error on "DataOption1:=xlSortNormal".



Sub Macro99()

LastRowColA = Range("c65536").End(xlUp).Row

ActiveCell.CurrentRegion.Sort _
Key1:=Intersect(ActiveCell.CurrentRegion,
ActiveCell.EntireRow).Cells(1, 1), _
Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub