View Single Post
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Danny,

You could change the code from

Selection.Sort Key1:=Range("B15"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


to

rng.Sort Key1:=rng.Range("B2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

to always sort based on the second column of the selected range.

HTH,
Bernie
MS Excel MVP


"Danny" wrote in message
...
Hi,

Last week, I posted a similar question and got and answer (thank you) to
resize a range. I got the following macro:

Sub Sort()

Clients '(name of macro to find this range)

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlUp).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

Selection.Sort Key1:=Range("B15"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

End With

End Sub

The first part of the macro would highlight the range to be sorted and it
works perfectly. However, the second part of the macro doesn't work if I try
to find ANOTHER RANGE to sort. Maybe it's because the range "B15" doesn't
match the cell of the "NEW Range"

Please help and thanks in advance.