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 / November 2007

Tip: Looking for answers? Try searching our database.

Sorting macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phrank - 16 Nov 2007 02:58 GMT
I have the following sort macro:

    Cells.Select
   Selection.Sort Key1:=Range("L2"), Order1:=xlAscending,
Header:=xlYes
   Range("A1").Select

This works just fine, but I may have occasion to add , remove, or move
a column.  Is there a way to have it sort on a named range?  This
would allow for the columns to change but still sort on the given
column without having to go back into the macro and change the Range.
I tried naming a column and having it sort that way, but I was given a
debug error (as below).  Thanks for any help.

    Cells.Select
   Selection.Sort Key1:=Range(Name), Order1:=xlAscending,
Header:=xlYes
   Range("A1").Select
Jim May - 16 Nov 2007 03:57 GMT
You'll likley need to put quotes (" ' s) around the Range Name

Selection.Sort Key1:=Range("Name"), Order1:=xlAscending,

> I have the following sort macro:
>
[quoted text clipped - 14 lines]
> Header:=xlYes
>     Range("A1").Select
Phrank - 16 Nov 2007 10:54 GMT
That worked!  Thanks Jim.

>You'll likley need to put quotes (" ' s) around the Range Name
>
[quoted text clipped - 18 lines]
>> Header:=xlYes
>>     Range("A1").Select
 
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.