View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Del Cotter Del Cotter is offline
external usenet poster
 
Posts: 560
Default Sorting a named range using first three columns

On Sat, 6 Sep 2008, in microsoft.public.excel.programming,
Dave Peterson said:

How do I sort using the first *three* columns as primary,
secondary and tertiary keys?


With worksheets("someworksheetnamehere").range("Sort_Ro ws")
.sort key1:=.columns(1), Order1:=xlAscending, _
key2:=.Columns(2), order2:=xlAscending, _
key3:=.Columns(3), order3:=xlAscending, _
header:=xlNo, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
end with


Thank you! That works great, and so does the column equivalent,
although for the moment I only want to sort by one key in that
direction.

I eliminated the "worksheets" part of the range reference, which I
assume makes the macro work on whatever worksheet is in focus at the
time? (SORT_ROWS is a name local to each sheet, and different for each
sheet)

--
Del Cotter
NB Personal replies to this post will send email to ,
which goes to a spam folder-- please send your email to del3 instead.