Thread: sorting range
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
peyman peyman is offline
external usenet poster
 
Posts: 189
Default sorting range

it's fine.I have no problem in Area that's selected.I need to know why it
only sorts the first "key" no matter which one is first.

"Joel" wrote:

The code wil onluy sort the selected area. try this test code and see what
is selected after it runs

sub test()

Areas(1).select

end sub

The area that is selected is the area that is sorted in you code.
"peyman" wrote:

hi,
I'm using the following code to sort a selected range based on the columns,
C,B and F.I don't know why the range is sorted only based on Column C?
Sub Rectangle1954_Click()
Dim myRng As Range
Set myRng = Selection.Areas(1)
With myRng
.Sort key1:=Columns("C"), order1:=xlAscending, header:=xlNo,
MatchCase:=False, Orientation:=xlTopToBottom, key2:=Columns("B"),
order1:=xlAscending, header:=xlNo, MatchCase:=False,
Orientation:=xlTopToBottom, key3:=Columns("F"), order1:=xlAscending,
header:=xlNo, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub

any help?
thanx