PDA

View Full Version : Sorting CurrentRegion?



infinity
10-15-2009, 07:27 AM
Hello,

I am trying to sort based on a CurrentRegion selection. I keep getting an error. Can anyone help?


activeCell.CurrentRegion.Select
Selection.Sort.SortFields.Add Key1:=Range("T1"), Order:=xlDescending, _
Key2:=Range("D1"), Order:=xlAscending, Header:=xlGuess, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption:=xlSortNormal


Thank you in advance!

Bob Phillips
10-15-2009, 07:50 AM
Where did you get this code? It seems to be a mix of 2007 and pre-2007 methods.

For 2007



With ActiveSheet.Sort
.SortFields.Add Key:=Range("T1"), Order:=xlDescending
.SortFields.Add Key:=Range("D1"), Order:=xlAscending
.SetRange ActiveCell.CurrentRegion
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With