#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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


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
Sort an array Gary''s Student Excel Programming 1 February 7th 06 02:47 PM
sort 2D array Greg Excel Programming 0 February 6th 06 09:31 PM
sort 2D array Greg Excel Programming 1 February 6th 06 09:29 PM
sort an array Greg Excel Programming 6 February 6th 06 04:07 AM
Sort an Array [email protected] Excel Programming 0 November 18th 04 01:20 AM


All times are GMT +1. The time now is 03:05 PM.

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

About Us

"It's about Microsoft Excel"