View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Shane Devenshire[_2_] Shane Devenshire[_2_] is offline
external usenet poster
 
Posts: 3,346
Default how to refine this Macro

Range("A7:M" & [I65536].End(xlup)).Sort _
Key1:=Range("M7"), _
Order1:=xlDescending, _
Key2:=Range("I7"), _
Order2:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Now you can probably simpliy this to

Range("A7:M" & [I65536].End(xlup)).Sort _
Key1:=Range("M7"), _
Order1:=xlDescending, _
Key2:=Range("I7"), _
Order2:=xlAscending, _
Header:=xlNo

Here I am assuming that you data goes from column A to M. I have laid it
out this way so that its easier to read.
--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


" wrote:

Hello,
with the help of this group I have created this Macro which I run from
a button, but I need to pre select the range.

Sub Sort_Fastest_Male_then_Female()
'
' Sort_Fastest_Male_then_Female Macro
' Macro recorded 6/06/2009 by Stephen Ditchfield
'

'
Selection.Sort Key1:=Range("M7"), Order1:=xlDescending, Key2:=Range
("I7") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:= _
xlSortNormal
End Sub

is there a way to modify it so I don't need to select the range then
run the Macro.
Can I just run the Macro and it finds the last used cell in I7 and
sorts leaving the Header rows (1 to 6) in place?
thanks again for all the help
regards
Ditchy
Ballarat, Australia