![]() |
Sort array
Hey, I have a large range of cells that I would like to be able to sor descending by one of the columns. Is it possible to do this using vba? I have looked into the bubblesor technique but i can't get it to work and the version that i saw woul sort the whole worksheet rather than a range of cells. Thanks in advance -- sli ----------------------------------------------------------------------- slim's Profile: http://www.excelforum.com/member.php...fo&userid=2864 View this thread: http://www.excelforum.com/showthread.php?threadid=52535 |
Sort array
What's wrong with standard Excel sort (which is usually much quicker than VBA
sorts)? "slim" wrote: Hey, I have a large range of cells that I would like to be able to sort descending by one of the columns. Is it possible to do this using vba? I have looked into the bubblesort technique but i can't get it to work and the version that i saw would sort the whole worksheet rather than a range of cells. Thanks in advance. -- slim ------------------------------------------------------------------------ slim's Profile: http://www.excelforum.com/member.php...o&userid=28643 View this thread: http://www.excelforum.com/showthread...hreadid=525357 |
Sort array
Why not use RangeObj.Sort method to do the sorting? You are not sorting an
array, so I think a custom sort algorithm, like bubble sort, is not relevant in your case. Frederick Chow Hong Kong. "slim" wrote in message ... Hey, I have a large range of cells that I would like to be able to sort descending by one of the columns. Is it possible to do this using vba? I have looked into the bubblesort technique but i can't get it to work and the version that i saw would sort the whole worksheet rather than a range of cells. Thanks in advance. -- slim ------------------------------------------------------------------------ slim's Profile: http://www.excelforum.com/member.php...o&userid=28643 View this thread: http://www.excelforum.com/showthread...hreadid=525357 |
Sort array
Hey, thanks for replying. I've solved the problem now with a handy bit of code from Microsoft! Sub SortRange() Dim MyErr As Label On Error GoTo MyErr Selection.Sort Key1:=Range("N5"), Order1:=xlAscending Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom MyErr: Select Case Err Case 0 'Everything is OK Case Else MsgBox Err.Description End Select Err.Clear End Sub Thanks for your help -- sli ----------------------------------------------------------------------- slim's Profile: http://www.excelforum.com/member.php...fo&userid=2864 View this thread: http://www.excelforum.com/showthread.php?threadid=52535 |
Sort array
Just for interest:
You could have gotten code like that by turning on the macro recorder, selecting your range and do Data=sort and specifying your parameters. Then turn off the macro recorder. -- Regards, Tom Ogilvy "slim" wrote: Hey, thanks for replying. I've solved the problem now with a handy bit of code from Microsoft! Sub SortRange() Dim MyErr As Label On Error GoTo MyErr Selection.Sort Key1:=Range("N5"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom MyErr: Select Case Err Case 0 'Everything is OK Case Else MsgBox Err.Description End Select Err.Clear End Sub Thanks for your help. -- slim ------------------------------------------------------------------------ slim's Profile: http://www.excelforum.com/member.php...o&userid=28643 View this thread: http://www.excelforum.com/showthread...hreadid=525357 |
All times are GMT +1. The time now is 09:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com