Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Sort array

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
slim - 22 Mar 2006 18:14 GMT
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
Toppers - 22 Mar 2006 18:31 GMT
What's wrong with standard Excel sort (which is usually much quicker than VBA
sorts)?

> Hey,
>
[quoted text clipped - 6 lines]
>
> Thanks in advance.
Frederick Chow - 22 Mar 2006 18:31 GMT
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.

> Hey,
>
[quoted text clipped - 6 lines]
>
> Thanks in advance.
slim - 22 Mar 2006 18:45 GMT
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
Tom Ogilvy - 22 Mar 2006 19:58 GMT
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.

Signature

Regards,
Tom Ogilvy

> Hey, thanks for replying.
>
[quoted text clipped - 18 lines]
>
> Thanks for your help.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.