#1   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Sorting in code

Can someone help me with this? The first sort works fine but the second sort
gives me an errormessage: The sort reference is not valid. Make sure that
it's within the data you want to sort, and the first Sort Box isn't the same
of Blank.
What does that mean?

Sheets("Sheet1").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
ActiveSheet.Range("D2:G" & ClastRow).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D2").Select

Sheets("BulkUploadReport 1 ").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
ActiveSheet.Range("A2:O" & ClastRow).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").Select
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Sorting in code

This is how IK do my sorts and never have any problems

with Sheets("Sheet1")
ClastRow = .Cells(Rows.Count, "D").End(xlUp).Row
.Range("D2:G" & ClastRow).Sort _
Key1:=.Range("D2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

with Sheets("BulkUploadReport 1 ")
ClastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A2:O" & ClastRow).Sort _
Key1:=.Range("B2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

"Ayo" wrote:

Can someone help me with this? The first sort works fine but the second sort
gives me an errormessage: The sort reference is not valid. Make sure that
it's within the data you want to sort, and the first Sort Box isn't the same
of Blank.
What does that mean?

Sheets("Sheet1").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
ActiveSheet.Range("D2:G" & ClastRow).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D2").Select

Sheets("BulkUploadReport 1 ").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
ActiveSheet.Range("A2:O" & ClastRow).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").Select

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Sorting in code

I just tried it and I got the same error message. I don't think that is the
problem.

"Joel" wrote:

This is how IK do my sorts and never have any problems

with Sheets("Sheet1")
ClastRow = .Cells(Rows.Count, "D").End(xlUp).Row
.Range("D2:G" & ClastRow).Sort _
Key1:=.Range("D2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

with Sheets("BulkUploadReport 1 ")
ClastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A2:O" & ClastRow).Sort _
Key1:=.Range("B2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

"Ayo" wrote:

Can someone help me with this? The first sort works fine but the second sort
gives me an errormessage: The sort reference is not valid. Make sure that
it's within the data you want to sort, and the first Sort Box isn't the same
of Blank.
What does that mean?

Sheets("Sheet1").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
ActiveSheet.Range("D2:G" & ClastRow).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D2").Select

Sheets("BulkUploadReport 1 ").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
ActiveSheet.Range("A2:O" & ClastRow).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").Select

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Sorting in code

Do you have any merged cells. Unmerge your cells are try to sort again.

"Ayo" wrote:

I just tried it and I got the same error message. I don't think that is the
problem.

"Joel" wrote:

This is how IK do my sorts and never have any problems

with Sheets("Sheet1")
ClastRow = .Cells(Rows.Count, "D").End(xlUp).Row
.Range("D2:G" & ClastRow).Sort _
Key1:=.Range("D2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

with Sheets("BulkUploadReport 1 ")
ClastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A2:O" & ClastRow).Sort _
Key1:=.Range("B2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

"Ayo" wrote:

Can someone help me with this? The first sort works fine but the second sort
gives me an errormessage: The sort reference is not valid. Make sure that
it's within the data you want to sort, and the first Sort Box isn't the same
of Blank.
What does that mean?

Sheets("Sheet1").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
ActiveSheet.Range("D2:G" & ClastRow).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D2").Select

Sheets("BulkUploadReport 1 ").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
ActiveSheet.Range("A2:O" & ClastRow).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").Select

  #5   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Sorting in code

No. there are no mere cells. If you don't mind I can send you the file and
maybe you can figure it out. It is a 365KB file.

"Joel" wrote:

Do you have any merged cells. Unmerge your cells are try to sort again.

"Ayo" wrote:

I just tried it and I got the same error message. I don't think that is the
problem.

"Joel" wrote:

This is how IK do my sorts and never have any problems

with Sheets("Sheet1")
ClastRow = .Cells(Rows.Count, "D").End(xlUp).Row
.Range("D2:G" & ClastRow).Sort _
Key1:=.Range("D2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

with Sheets("BulkUploadReport 1 ")
ClastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A2:O" & ClastRow).Sort _
Key1:=.Range("B2"), _
Order1:=xlAscending, _
Header:=xlGuess
end with

"Ayo" wrote:

Can someone help me with this? The first sort works fine but the second sort
gives me an errormessage: The sort reference is not valid. Make sure that
it's within the data you want to sort, and the first Sort Box isn't the same
of Blank.
What does that mean?

Sheets("Sheet1").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
ActiveSheet.Range("D2:G" & ClastRow).Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("D2").Select

Sheets("BulkUploadReport 1 ").Select
ClastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
ActiveSheet.Range("A2:O" & ClastRow).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").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
Sorting by code Jay Excel Discussion (Misc queries) 1 February 8th 08 05:55 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
sorting code Larry Excel Discussion (Misc queries) 5 August 2nd 06 07:40 AM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
12 digit code sorting Mark Excel Worksheet Functions 5 October 31st 05 10:21 PM


All times are GMT +1. The time now is 03:34 PM.

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"