Dave Peterson replied to cate
21-Nov-09 08:42 AM
Most things that you do in excel do not need to have the objects (like ranges or
worksheets) selected first.
You could use code like:
Option Explicit
Sub trythis()
Dim wks As Worksheet
Dim myRng As Range
Set wks = ActiveSheet
With wks
'I like this first line--I find it more self-documenting
Set myRng = .Range(.Range("RStart"), .Range("RLast"))
'but you could use either of these, too.
'Set myRng = .Range("Rstart", "rlast")
'Set myRng = .Range("Rstart:Rlast")
End With
With myRng
.Sort Key1:=.Columns(2), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
--
Dave Peterson