Thread: Use sort in VBA
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.robinson@it-tallaght.ie is offline
external usenet poster
 
Posts: 789
Default Use sort in VBA

Hi
This will sort a worksheet range called "TestRange" on the activesheet.
It willleave the first row (headings) alone

Public Sub SortTheTestRange()
Dim DataRange As Range
Set DataRange = ActiveSheet.Range("TestRange")
With DataRange
.Sort _
Key1:=.Cells(1, 1), Order1:=xlAscending, _
Key2:=.Cells(1, 2), Order2:=xlAscending, _
Key3:=.Cells(1, 3), Order3:=xlAscending, _
header:=xlYes 'first row is not sorted
End With
End Sub

regards
Paul