Syntex Error ??

P

Paul Cooke

Would someone mind heaving a look at this segment of code and letting me
know if they can see whats wrong with it please.

Many thanks


Paul


'Sort by ID number
Range("A1").CurrentRegion.Sort Key1:=Range("F2"), Order1:=xlAscending,
Header:=xlYes, _
Orientation:=xlTopToBottom
 
S

swatsp0p

You don't indicate what kind of failure you are getting (not working at
all, unexpected results, etc.), but: Range("A1").CurrentRegion.Sort
Key1:=Range("F2"), Your range starts in A1, your sort key starts in F2.
Try F1?

This code is tested and works for a multiple level sort...


Code:
--------------------
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("E4") _
, Order2:=xlAscending, Key3:=Range("F4"), Order3:=xlAscending, HEADER:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
--------------------

This selects all contiguous rows/columns with data from A1 down and
over... then sorts by Cols. A, E and F.

good luck
 
P

Peter Rooney

Paul,

You haven't got a space and an underscore character at the end of the first
line... I think!

regards

Pete
 
P

Paul Cooke

Hi

Many thanks for your reply, your code has solved the problem and work
great.

Thanks again for taking the time to reply

Best regards


Pau
 
S

swatsp0p

I'm glad it worked for you. Thanks for the feedback, it is always
appreciated.

Cheers!
 
Top