Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort selected range
How do I input the code to sort the selected range from here?
The range may be any row, so leave that portion open/variable. Range("D65534").Select Selection.End(xlUp).Select Range(Selection, Selection.End(xlToRight)).Select |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort selected range
Set rng = Range("D65534").End(xlUp)
Set rng = Range(rng, rng.End(xlToRight)) rng.Sort Key1:=rng.Cells(1, 1), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal -- __________________________________ HTH Bob "J.W. Aldridge" wrote in message ... How do I input the code to sort the selected range from here? The range may be any row, so leave that portion open/variable. Range("D65534").Select Selection.End(xlUp).Select Range(Selection, Selection.End(xlToRight)).Select |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort selected range
getting error on this portion....
rng.Sort Key1:=rng.Cells(1, 1), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal "application defined or object defined error" |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort selected range
That range Set will "break" if there are any blank cells in Column D's last
filled row anywhere to the right of Column D. This Set statement should work for that condition as well as a range with no blank cells in the indicated row)... Set rng = Cells(Rows.Count, "D").End(xlUp).Resize(, Columns.Count - 3) The 3 at the end is one less than the column's number value (Column "D" in this case, which is column number 4, and one less than that is the 3 that I used). -- Rick (MVP - Excel) "Bob Phillips" wrote in message ... Set rng = Range("D65534").End(xlUp) Set rng = Range(rng, rng.End(xlToRight)) rng.Sort Key1:=rng.Cells(1, 1), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal -- __________________________________ HTH Bob "J.W. Aldridge" wrote in message ... How do I input the code to sort the selected range from here? The range may be any row, so leave that portion open/variable. Range("D65534").Select Selection.End(xlUp).Select Range(Selection, Selection.End(xlToRight)).Select |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort selected range
See if this is better
Set rng = Range("D65534").End(xlUp) Set rng = Range(rng, rng.End(xlToRight)) rng.Sort Key1:=rng.Cells(1, 1), _ Order1:=xlAscending, _ Header:=xlGuess, _ OrderCustom:=1, _ MatchCase:=False, _ Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal -- __________________________________ HTH Bob "J.W. Aldridge" wrote in message ... getting error on this portion.... rng.Sort Key1:=rng.Cells(1, 1), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal "application defined or object defined error" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sort of range leaves range "selected" | Excel Programming | |||
Selected Sort | Excel Programming | |||
excel - sort, selected rows?? | Excel Worksheet Functions | |||
when I auto sort in excel, How do I know how many are selected? | Excel Worksheet Functions | |||
How to sort on the row selected by user? | Excel Programming |