Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Sort reference is not valid

I have read other post concerning sorting with macros, but I cannot find any
information as to why my code will not work. I am receiving the error message

€œRun-time error €˜1004:
The sort reference is not valid. Make sure that its within the data you
want to sort, and the first Sort By box isnt the same or blank.€

The sort code and the worksheet selection code is below. Does anyone have
any suggestions?

Thanks!

Worksheets("75851_Plasticity_All").Range("A:B").Se lect
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort reference is not valid

I would drop the .selects

with Worksheets("75851_Plasticity_All")
with .Range("A:B")
.Sort Key1:=.columns(2), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with
end with

And if you know if your data has headers, you don't have to let excel guess.
I'd put xlno or xlyes as the Header parm.

Freddy wrote:

I have read other post concerning sorting with macros, but I cannot find any
information as to why my code will not work. I am receiving the error message

€œRun-time error €˜1004:
The sort reference is not valid. Make sure that its within the data you
want to sort, and the first Sort By box isnt the same or blank.€

The sort code and the worksheet selection code is below. Does anyone have
any suggestions?

Thanks!

Worksheets("75851_Plasticity_All").Range("A:B").Se lect
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Sort reference is not valid

Thanks Dave - This worked great!

"Dave Peterson" wrote:

I would drop the .selects

with Worksheets("75851_Plasticity_All")
with .Range("A:B")
.Sort Key1:=.columns(2), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with
end with

And if you know if your data has headers, you don't have to let excel guess.
I'd put xlno or xlyes as the Header parm.

Freddy wrote:

I have read other post concerning sorting with macros, but I cannot find any
information as to why my code will not work. I am receiving the error message

€œRun-time error €˜1004€„¢:
The sort reference is not valid. Make sure that it€„¢s within the data you
want to sort, and the first Sort By box isn€„¢t the same or blank.€Â

The sort code and the worksheet selection code is below. Does anyone have
any suggestions?

Thanks!

Worksheets("75851_Plasticity_All").Range("A:B").Se lect
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Sort reference is not valid

Hi Dave,

Do you have any thoughts on why the code you suggested below will work with
Excel XP but not with 2000?

Thanks,

Freddy

"Dave Peterson" wrote:

I would drop the .selects

with Worksheets("75851_Plasticity_All")
with .Range("A:B")
.Sort Key1:=.columns(1), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with
end with

And if you know if your data has headers, you don't have to let excel guess.
I'd put xlno or xlyes as the Header parm.

Freddy wrote:

I have read other post concerning sorting with macros, but I cannot find any
information as to why my code will not work. I am receiving the error message

€œRun-time error €˜1004€„¢:
The sort reference is not valid. Make sure that it€„¢s within the data you
want to sort, and the first Sort By box isn€„¢t the same or blank.€Â

The sort code and the worksheet selection code is below. Does anyone have
any suggestions?

Thanks!

Worksheets("75851_Plasticity_All").Range("A:B").Se lect
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort reference is not valid

dataoption1 was added in xl2002.

Remove that parm and the preceding comma and it should work.

Freddy wrote:

Hi Dave,

Do you have any thoughts on why the code you suggested below will work with
Excel XP but not with 2000?

Thanks,

Freddy

"Dave Peterson" wrote:

I would drop the .selects

with Worksheets("75851_Plasticity_All")
with .Range("A:B")
.Sort Key1:=.columns(1), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with
end with

And if you know if your data has headers, you don't have to let excel guess.
I'd put xlno or xlyes as the Header parm.

Freddy wrote:

I have read other post concerning sorting with macros, but I cannot find any
information as to why my code will not work. I am receiving the error message

€œRun-time error €˜1004€„¢:
The sort reference is not valid. Make sure that it€„¢s within the data you
want to sort, and the first Sort By box isn€„¢t the same or blank.€Â

The sort code and the worksheet selection code is below. Does anyone have
any suggestions?

Thanks!

Worksheets("75851_Plasticity_All").Range("A:B").Se lect
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Sort reference is not valid

That works. Thanks Dave!

"Dave Peterson" wrote:

dataoption1 was added in xl2002.

Remove that parm and the preceding comma and it should work.

Freddy wrote:

Hi Dave,

Do you have any thoughts on why the code you suggested below will work with
Excel XP but not with 2000?

Thanks,

Freddy

"Dave Peterson" wrote:

I would drop the .selects

with Worksheets("75851_Plasticity_All")
with .Range("A:B")
.Sort Key1:=.columns(1), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end with
end with

And if you know if your data has headers, you don't have to let excel guess.
I'd put xlno or xlyes as the Header parm.

Freddy wrote:

I have read other post concerning sorting with macros, but I cannot find any
information as to why my code will not work. I am receiving the error message

€ŀœRun-time error €˜1004€„¢:
The sort reference is not valid. Make sure that it€„¢s within the data you
want to sort, and the first Sort By box isn€„¢t the same or blank.€ÂÂ

The sort code and the worksheet selection code is below. Does anyone have
any suggestions?

Thanks!

Worksheets("75851_Plasticity_All").Range("A:B").Se lect
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

--

Dave Peterson


--

Dave Peterson

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
External Reference Not Valid ? dim Excel Worksheet Functions 2 January 1st 08 09:28 PM
'reference is not valid' Tim Excel Discussion (Misc queries) 12 June 21st 06 07:36 PM
hyperlink reference not valid Dannycol Excel Worksheet Functions 0 April 10th 06 03:36 PM
? Hyperlink; reference not valid ? [email protected] Excel Discussion (Misc queries) 1 March 7th 06 10:40 PM
Reference is not valid Steved Excel Worksheet Functions 1 January 30th 06 10:56 PM


All times are GMT +1. The time now is 06:26 AM.

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

About Us

"It's about Microsoft Excel"