Skip to content

Latest commit

 

History

History
72 lines (46 loc) · 1.71 KB

Word.Table.SortDescending.md

File metadata and controls

72 lines (46 loc) · 1.71 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Table.SortDescending method (Word)
vbawd10.chm156303373
vbawd10.chm156303373
Word.Table.SortDescending
a72b25e9-06c2-8f2f-1dff-796768d43fff
06/08/2017
medium

Table.SortDescending method (Word)

Sorts table rows in descending alphanumeric order.

Syntax

expression. SortDescending

expression Required. A variable that represents a 'Table' object.

Remarks

The first table row is considered a header record and isn't included in the sort. Use the Sort method to include the header record in a sort.

This method offers a simplified form of sorting intended for mail-merge data sources that contain columns of data. For most sorting tasks, use the Sort method.

Example

This example creates a 5x5 table in a new document, inserts text into each cell, and then sorts the table in descending alphanumeric order.

Set newDoc = Documents.Add 
Set myTable = _ 
 newDoc.Tables.Add(Range:=Selection.Range, NumRows:=5, _ 
 NumColumns:=5) 
For iRow = 1 To myTable.Rows.Count 
 For iCol = 1 To myTable.Columns.Count 
 Set MyRange = myTable.Rows(iRow).Cells(iCol).Range 
 MyRange.InsertAfter "Cell" & Str$(iRow) & "," & Str$(iCol) 
 Next iCol 
Next iRow 
MsgBox "Click OK to sort in descending order." 
myTable.SortDescending

This example sorts the table that contains the insertion point in descending alphanumeric order.

If Selection.Information(wdWithInTable) = True Then 
 Selection.Tables(1).SortDescending 
Else 
 MsgBox "The insertion point is not in a table." 
End If

See also

Table Object

[!includeSupport and feedback]