#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
This works for me:
Code:
Sub Demo() Dim Rng As Range With ActiveDocument.Tables(1) Set Rng = .Range With Rng .Start = .Rows(3).Range.Start .Sort End With End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks, that looks good to me!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sorting a Word table containing cross-references | mpdsal | Word Tables | 5 | 02-13-2013 06:44 PM |
Sorting Challenge | gbaker | Excel Programming | 11 | 06-22-2012 09:39 AM |
Sorting by certain criteria | randenius | Excel | 2 | 06-11-2012 02:18 AM |
Need help in aplhabetica sorting | brooklyn86 | Word VBA | 1 | 06-05-2012 11:43 AM |
Show part codes only whose have Book qty bal.in Pivot table | PRADEEPB270 | Excel | 2 | 02-15-2012 04:09 AM |