sorting unknown range

H

Helmut

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
 
M

Mike H

Hi,

Maybe this

Sub Sort()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A11:J" & lastrow)
Rng.Select
Selection.Sort Key1:=Range("A11"), Order1:=xlDescending
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Modify Sort Routine to inlcude All Data 2
Sort code fails 1
Undo Macro Action 3
Sorting Question 5
Bombing on final sort command . . . 7
VBA 2 Codes 2
Clear Check Box 2
Pictures not being sorted in VBA 2

Top