Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Counting an Unknown Range | Excel Discussion (Misc queries) | |||
sorting unknown range | Excel Discussion (Misc queries) | |||
HELP! Unknown range | Excel Worksheet Functions | |||
sorting through unknown source data as it is entered | Excel Worksheet Functions | |||
Sorting based on the first column of a defined name range (Unknown) | Excel Programming |