PC Review


Reply
Thread Tools Rate Thread

can't sort a list

 
 
bigjim
Guest
Posts: n/a
 
      13th May 2009
I'm using the following code in excel 2003 trying to sort a column of text
values:

ActiveWorkbook.Sheets("cost sheet").Range("a100:a200").Select
Selection.Sort Key1:=Range("a100"), Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

I get an error: "Sort reference is not valid. make sure it's withing the
data ou want to sort and the first sort by box isn't the same or blank.

Most of the cells are blank and all are formatted as text.

Any help would be appreciated


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      13th May 2009
I'm gonna guess that it's that unqualified range object:

Selection.Sort Key1:=Range("a100"), ....
should be:

Selection.Sort Key1:=ActiveWorkbook.Sheets("cost sheet").Range("a100")

Or without selecting...

with ActiveWorkbook.Sheets("cost sheet").Range("a100:a200")
.Sort Key1:=.columns(1), Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
end with

bigjim wrote:
>
> I'm using the following code in excel 2003 trying to sort a column of text
> values:
>
> ActiveWorkbook.Sheets("cost sheet").Range("a100:a200").Select
> Selection.Sort Key1:=Range("a100"), Order1:=xlDescending, Header:=xlNo, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
>
> I get an error: "Sort reference is not valid. make sure it's withing the
> data ou want to sort and the first sort by box isn't the same or blank.
>
> Most of the cells are blank and all are formatted as text.
>
> Any help would be appreciated


--

Dave Peterson
 
Reply With Quote
 
bigjim
Guest
Posts: n/a
 
      13th May 2009
that was it. thanks
Jim

"Dave Peterson" wrote:

> I'm gonna guess that it's that unqualified range object:
>
> Selection.Sort Key1:=Range("a100"), ....
> should be:
>
> Selection.Sort Key1:=ActiveWorkbook.Sheets("cost sheet").Range("a100")
>
> Or without selecting...
>
> with ActiveWorkbook.Sheets("cost sheet").Range("a100:a200")
> .Sort Key1:=.columns(1), Order1:=xlDescending, Header:=xlNo, _
> OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
> end with
>
> bigjim wrote:
> >
> > I'm using the following code in excel 2003 trying to sort a column of text
> > values:
> >
> > ActiveWorkbook.Sheets("cost sheet").Range("a100:a200").Select
> > Selection.Sort Key1:=Range("a100"), Order1:=xlDescending, Header:=xlNo, _
> > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
> >
> > I get an error: "Sort reference is not valid. make sure it's withing the
> > data ou want to sort and the first sort by box isn't the same or blank.
> >
> > Most of the cells are blank and all are formatted as text.
> >
> > Any help would be appreciated

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want sort a list but the sort is unlit on the home tab how do I chetrx Microsoft Excel Worksheet Functions 3 14th Nov 2008 11:47 PM
Sort tasks by due date and category in to do list, daily task list MLou Microsoft Outlook Calendar 1 12th Jun 2008 11:59 PM
Code to automatically sort a list, each time that a new entry isadded to the bottom of the list Mike C Microsoft Excel Programming 5 13th Apr 2008 04:59 PM
Excel sort by Fill Color by custom list sort =?Utf-8?B?RGFzaDRDYXNo?= Microsoft Excel Misc 2 29th Jul 2005 10:45 PM
sort list of players by team from player list on separate sheet =?Utf-8?B?Um9iZXJ0?= Microsoft Excel Worksheet Functions 1 19th Jul 2005 01:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:22 PM.