![]() |
Sort variable range in descending order
Code below works fine but need range to be variable. May not be R61c4
(row 61). Need to sort on whatever row lands. Sub Up_N_Fix() ' Range("D65536").Select Selection.End(xlUp).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Sort Key1:="R61C4", Order1:=xlDescending, Type:=xlSortValues, _ OrderCustom:=1, Orientation:=xlLeftToRight End Sub Thanx |
Sort variable range in descending order
On Mar 19, 11:04*am, "J.W. Aldridge"
wrote: Code below works fine but need range to be variable. May not be R61c4 (row 61). Need to sort on whatever row lands. Sub Up_N_Fix() ' * * Range("D65536").Select * * Selection.End(xlUp).Select * * Range(Selection, Selection.End(xlToRight)).Select * * Selection.Sort Key1:="R61C4", Order1:=xlDescending, Type:=xlSortValues, _ * * * * OrderCustom:=1, Orientation:=xlLeftToRight End Sub Thanx J.W. Aldridge, I think this is what you are looking to do. I did the generic sort parameters, so you can change those to what you want. Best, Matt Herbert Sub Up_N_Fix() Dim rngSort As Range Dim lngStartRow As Long Dim lngEndCol As Long Dim rngSortCell As Range Set rngSort = Range("D65536").End(xlUp).CurrentRegion lngStartRow = rngSort.Cells(1).Row lngEndCol = rngSort.Cells(rngSort.Cells.Count).Column Set rngSortCell = Cells(lngStartRow, lngEndCol) rngSort.Sort Key1:=rngSortCell, Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End Sub |
Sort variable range in descending order
Thanx, I believe this would work however I am getting all sorts of
compile errors. trying to fix the arrangements but to no luck thus far. |
Sort variable range in descending order
On Mar 19, 11:36*am, "J.W. Aldridge"
wrote: Thanx, I believe this would work however I am getting all sorts of compile errors. trying to fix the arrangements but to no luck thus far. J.W., The code won't simply work if you copy and paste it from groups.google into your code module. If you simply copy and paste, you will get a lot of red text in your code module. This is because your line continuation characters, i.e. "_" need to be at the end of a line. Another option is to delete all spacing such that the line starting "rngSort.Sort..." is on one line. Matt Herbert |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com