Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Sorting macro

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

You'll likley need to put quotes (" ' s) around the Range Name

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

"Phrank" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Sorting macro

That worked! Thanks Jim.

On Thu, 15 Nov 2007 19:57:00 -0800, Jim May
wrote:

You'll likley need to put quotes (" ' s) around the Range Name

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

"Phrank" wrote:

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

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
Looking for help with a sorting macro. [email protected] Excel Programming 3 August 24th 07 09:20 PM
Sorting in a macro Don Wiss Excel Programming 9 January 13th 05 03:39 AM
Macro for Sorting SiRCYRO Excel Programming 0 September 9th 03 07:35 PM
Sorting with a macro? gschimek Excel Programming 2 August 29th 03 09:57 PM
Sorting w/Macro Joe[_24_] Excel Programming 1 August 28th 03 07:44 PM


All times are GMT +1. The time now is 05:33 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"