View Single Post
 
Old 06-18-2014, 01:06 PM
Cosmo Cosmo is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default Sorting part of a table

I need to sort a table, but leave the first 2 rows out of the sort (the first row is a general header, the second is a column header)

The table's sort method appears to only allow excluding a single header row, so I am sorting using a selection:

Code:
Dim rng As Range
Dim ct As Integer
With tbl
    ct = .Rows.Count
    If (ct > 2) Then
        Set rng = .Rows(3).Range
        rng.End = .Rows(ct).Range.End
        rng.Select
        Call Selection.Sort(ExcludeHeader:=False, FieldNumber:=1, SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending) 
    End If
End With
Is this the best/only way to do this? I would prefer not using a selection, if that is possible.
Reply With Quote