Sort Method

Microsoft Office Web Components Visual Basic

expression.Sort(ColumnKey, Order, Header)

expression    An expression that returns a Range object.

ColumnKey    Optional Long. The number of the first sort column. The default value is 1.

Order    Optional XlSortOrder . The sort order.

Header   Optional XlYesNoGuess . Determines whether the first row contains headers.

Example

This example sorts the range A1:F10 in descending order based on column B.

Sub SortData()
Dim ssConstants

Set ssConstants = Spreadsheet1.Constants

' Sort Range A1:F10 on column B in descending order and specify that
' row 1 contains headings.
Spreadsheet1.ActiveSheetRange("A1:F10").Sort 2, _
ssConstants.xlDescending, ssConstants.xlYes
End Sub