Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code for variable sort order | Excel Discussion (Misc queries) | |||
How to order chart in descending order of Freq? | Charts and Charting in Excel | |||
For Each Sheet in Range - Sort Descending | Excel Worksheet Functions | |||
How to sort worksheets in alphabetical order (descending or ascending)? | Excel Discussion (Misc queries) | |||
Excel worksheets needs to sort ascending or descending order. | Excel Worksheet Functions |