![]() |
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 |
sorting unknown range
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 "Helmut" wrote: 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 |
All times are GMT +1. The time now is 05:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com