.Sort.SortFields

M

MESTRELLA29

Problem... I am downoading mi data to excel, after that I have this macro
that sorts the information by coulum A, but it is only sorting .SetRange
Range("A11:N95"), this is ther range when i created the macro, how do I sort
the selected range insted of the Raneg Set by the recorded macro.


Range("A11").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveWorkbook.Worksheets("Recovered_Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Recovered_Sheet1").Sort.SortFields.Add
Key:=Range( _
"A11"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Recovered_Sheet1").Sort
.SetRange Range("A11:N95")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
 
D

Dave Peterson

with selection
.Cells.Sort key1:=.Columns(1), order1:=xlAscending, _
Header:=xlno, MatchCase:=False, Orientation:=xlTopToBottom
End with
 

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
Undo Macro Action 3
Sorting Question 5
vba dynamic 1
VBA 2 Codes 2
Clear Check Box 2
Stay on Active Sheet 2
Sort WorkSheetName unknown 9

Top