Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default 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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code for variable sort order Jacob Skaria Excel Discussion (Misc queries) 1 April 28th 10 02:26 PM
How to order chart in descending order of Freq? Gary Charts and Charting in Excel 1 October 1st 09 01:03 PM
For Each Sheet in Range - Sort Descending NPell Excel Worksheet Functions 7 September 2nd 08 01:31 PM
How to sort worksheets in alphabetical order (descending or ascending)? [email protected] Excel Discussion (Misc queries) 2 June 14th 07 10:13 PM
Excel worksheets needs to sort ascending or descending order. Md. Mahfuzul Mannan Excel Worksheet Functions 1 September 3rd 06 05:04 PM


All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"