ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   .Sort.SortFields (https://www.excelbanter.com/excel-programming/422189-sort-sortfields.html)

MESTRELLA29

.Sort.SortFields
 
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


Dave Peterson

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


MESTRELLA29 wrote:

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


--

Dave Peterson

MESTRELLA29

.Sort.SortFields
 
Excelente!!!!!

Gracias!!!!

HAPPY NEW YEAR ! ! !

"Dave Peterson" wrote:

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


MESTRELLA29 wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com