#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Sort Errors

Help! I can't get a sort to run correctly; both are "sort method of range
class failed";
I'm running this on Excel 2003

This is a macro-based code:

Columns("D:D").Select
Range("B1:U500").SORT Key1:=Range("D1"), Order1:=xlDescending, Key2:= _
Range("E1"), Order2:=xlAscending, Key3:=Range("G1"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal


I also can't get this (preferred) code to work:

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("U1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With

Suzanne
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sort Errors

columns U and B are backwards

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("B1"), .Cells(Rows.Count, "U").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With


"Suzanne" wrote:

Help! I can't get a sort to run correctly; both are "sort method of range
class failed";
I'm running this on Excel 2003

This is a macro-based code:

Columns("D:D").Select
Range("B1:U500").SORT Key1:=Range("D1"), Order1:=xlDescending, Key2:= _
Range("E1"), Order2:=xlAscending, Key3:=Range("G1"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal


I also can't get this (preferred) code to work:

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("U1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With

Suzanne

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Sort Errors

There must be something else going on here. I tested your prefered code and
it worked fine by me. The one thing that I notice is that your key work Sort
is all caps. Have you declared a procedure or sub or ??? somewhere called
SORT. If so then that could be the problem...

Sub test()
With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("U1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.Sort Key1:=.Cells(2, "D"), Order1:=xlDescending, _
Key2:=.Cells(2, "E"), Order2:=xlAscending, _
Key3:=.Cells(2, "G"), Order3:=xlAscending, _
MatchCase:=False, Header:=xlYes
End With
End Sub
--
HTH...

Jim Thomlinson


"Suzanne" wrote:

Help! I can't get a sort to run correctly; both are "sort method of range
class failed";
I'm running this on Excel 2003

This is a macro-based code:

Columns("D:D").Select
Range("B1:U500").SORT Key1:=Range("D1"), Order1:=xlDescending, Key2:= _
Range("E1"), Order2:=xlAscending, Key3:=Range("G1"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal


I also can't get this (preferred) code to work:

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("U1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With

Suzanne

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Sort Errors

The order in which B and U appear makes no difference in terms of creating a
range object. In this case if B is always populated to the end of the data
set but U may not have data all the way to the end, the way that the OP has
created the code is correct. Yours may end up missing some rows.
--
HTH...

Jim Thomlinson


"Joel" wrote:

columns U and B are backwards

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("B1"), .Cells(Rows.Count, "U").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With


"Suzanne" wrote:

Help! I can't get a sort to run correctly; both are "sort method of range
class failed";
I'm running this on Excel 2003

This is a macro-based code:

Columns("D:D").Select
Range("B1:U500").SORT Key1:=Range("D1"), Order1:=xlDescending, Key2:= _
Range("E1"), Order2:=xlAscending, Key3:=Range("G1"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal


I also can't get this (preferred) code to work:

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("U1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With

Suzanne

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Sort Errors

This didn't fix it at all... the command wouldn't even run.

I thought that Range was the last column ("U") and the Rows.Count was the
starting point.


"Joel" wrote:

columns U and B are backwards

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("B1"), .Cells(Rows.Count, "U").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With


"Suzanne" wrote:

Help! I can't get a sort to run correctly; both are "sort method of range
class failed";
I'm running this on Excel 2003

This is a macro-based code:

Columns("D:D").Select
Range("B1:U500").SORT Key1:=Range("D1"), Order1:=xlDescending, Key2:= _
Range("E1"), Order2:=xlAscending, Key3:=Range("G1"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal


I also can't get this (preferred) code to work:

With ActiveSheet

Dim Rng As Range
Set Rng = .Range(.Range("U1"), .Cells(Rows.Count, "B").End(xlUp))

Rng.SORT Key1:=.Cells(2, "D"), Order1:=xlDescending, Key2:=.Cells(2, "E"),
Order2:=xlAscending, Key3:=.Cells(2, "G"), Order3:=xlAscending,
MatchCase:=False, Header:=xlYes

End With

Suzanne

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
Excel Throwing Circular Errors When No Errors Exist MDW Excel Worksheet Functions 1 August 10th 06 02:15 PM
Trying to sort by row and getting errors. [email protected] New Users to Excel 2 June 12th 06 02:30 AM
Sort creating total errors excel idiot Excel Discussion (Misc queries) 7 January 16th 05 03:21 PM
how do I sort email address, dedupes,check for errors in a docume. varun Excel Discussion (Misc queries) 2 January 14th 05 11:41 PM
Unresolved Errors in IF Statements - Errors do not show in results Markthepain Excel Worksheet Functions 2 December 3rd 04 08:49 AM


All times are GMT +1. The time now is 11:54 AM.

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"