View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Helmut Helmut is offline
external usenet poster
 
Posts: 111
Default sorting unknown range

Help...I am getting ERROR on ".Apply"
Sub Sort()
' Set Range for Sorting
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A11:J" & lastrow)

Rng.Select
Range("A11").Activate

ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add _
Key:=Rng _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Rng
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub