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