Share via


Range.SortSpecial Method

Uses East Asian sorting methods to sort the range or a PivotTable report, or uses the method for the active region if the range contains only one cell. For example, Japanese sorts in the order of the Kana syllabary.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function SortSpecial ( _
    SortMethod As XlSortMethod, _
    Key1 As Object, _
    Order1 As XlSortOrder, _
    Type As Object, _
    Key2 As Object, _
    Order2 As XlSortOrder, _
    Key3 As Object, _
    Order3 As XlSortOrder, _
    Header As XlYesNoGuess, _
    OrderCustom As Object, _
    MatchCase As Object, _
    Orientation As XlSortOrientation, _
    DataOption1 As XlSortDataOption, _
    DataOption2 As XlSortDataOption, _
    DataOption3 As XlSortDataOption _
) As Object
'Usage
Dim instance As Range
Dim SortMethod As XlSortMethod
Dim Key1 As Object
Dim Order1 As XlSortOrder
Dim Type As Object
Dim Key2 As Object
Dim Order2 As XlSortOrder
Dim Key3 As Object
Dim Order3 As XlSortOrder
Dim Header As XlYesNoGuess
Dim OrderCustom As Object
Dim MatchCase As Object
Dim Orientation As XlSortOrientation
Dim DataOption1 As XlSortDataOption
Dim DataOption2 As XlSortDataOption
Dim DataOption3 As XlSortDataOption
Dim returnValue As Object

returnValue = instance.SortSpecial(SortMethod, _
    Key1, Order1, Type, Key2, Order2, Key3, _
    Order3, Header, OrderCustom, MatchCase, _
    Orientation, DataOption1, DataOption2, _
    DataOption3)
Object SortSpecial(
    XlSortMethod SortMethod,
    Object Key1,
    XlSortOrder Order1,
    Object Type,
    Object Key2,
    XlSortOrder Order2,
    Object Key3,
    XlSortOrder Order3,
    XlYesNoGuess Header,
    Object OrderCustom,
    Object MatchCase,
    XlSortOrientation Orientation,
    XlSortDataOption DataOption1,
    XlSortDataOption DataOption2,
    XlSortDataOption DataOption3
)

Parameters

  • SortMethod
    Type: Microsoft.Office.Interop.Excel.XlSortMethod

    Optional XlSortMethod. The type of sort. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed. Can be one of the following XlSortMethod constants:

    • xlStroke. Sorting by the quantity of strokes in each character.

    • xlPinYindefault. Phonetic Chinese sort order for characters.

  • Key1
    Type: System.Object

    Optional Object. The first sort field, as either text (a PivotTable field or range name) or a Range object ("Dept" or Cells(1, 1), for example).

  • Order1
    Type: Microsoft.Office.Interop.Excel.XlSortOrder

    Optional XlSortOrder. The sort order for the field or range specified in the Key1 argument. Can be one of the following XlSortOrder constants:

    • xlDescending. Sorts Key1 in descending order.

    • xlAscendingdefault. Sorts Key1 in ascending order.

  • Type
    Type: System.Object

    Optional Object. Specifies which elements are to be sorted. Use this argument only when sorting PivotTable reports.

  • Key2
    Type: System.Object

    Optional Object. The second sort field, as either text (a PivotTable field or range name) or a Range object. If you omit this argument, there’s no second sort field. Cannot be used when sorting PivotTable reports. Can be one of the following XlSortType constants:

    • xlSortLabels. Sorts the PivotTable report by labels.

    • xlSortValues. Sorts the PivotTable report by values.

  • Order2
    Type: Microsoft.Office.Interop.Excel.XlSortOrder

    Optional XlSortOrder. The sort order for the field or range specified in the Key2 argument. Cannot be used when sorting PivotTable reports. Can be one of the following XlSortOrder constants:

    • xlDescending. Sorts Key2 in descending order

    • xlAscending default. Sorts Key2 in ascending order.

  • Key3
    Type: System.Object

    Optional object. The third sort field, as either text (a range name) or a Range object. If you omit this argument, there’s no third sort field. Cannot be used when sorting PivotTable reports.

  • Order3
    Type: Microsoft.Office.Interop.Excel.XlSortOrder

    Optional XlSortOrder. The sort order for the field or range specified in the Key3 argument. Cannot be used when sorting PivotTable reports. Can be one of the following XlSortOrder constants:

    • xlDescending. Sorts Key3 in descending order.

    • xlAscendingdefault. Sorts Key3 in ascending order.

  • Header
    Type: Microsoft.Office.Interop.Excel.XlYesNoGuess

    Optional XlYesNoGuess. Specifies whether or not the first row contains headers. Cannot be used when sorting PivotTable reports. Can be one of the following XlYesNoGuess constants:

    • xlGuess. Lets Microsoft Excel determine whether there’s a header, and determine where it is if there is one.

    • xlNodefault. The entire range should be sorted.

    • xlYes. The entire range should not be sorted.

  • OrderCustom
    Type: System.Object

    Optional Object. This argument is a one-based integer offset to the list of custom sort orders. If you omit OrderCustom, (normal sort order) is used.

  • MatchCase
    Type: System.Object

    Optional Object. True to do a case-sensitive sort; False to do a sort that’s not case sensitive. Cannot be used when sorting PivotTable reports.

  • DataOption1
    Type: Microsoft.Office.Interop.Excel.XlSortDataOption

    Optional XlSortDataOption. Specifies how to sort text in Key1. Cannot be used when sorting PivotTable reports. Can be one of the following XlSortDataOption constants:

    • xlSortTextAsNumbers. Treats text as numeric data for the sort.

    • xlSortNormaldefault. Sorts numeric and text data separately.

  • DataOption2
    Type: Microsoft.Office.Interop.Excel.XlSortDataOption

    Optional XlSortDataOption. Specifies how to sort text in Key 2. Cannot be used when sorting PivotTable reports. Can be one of the following XlSortDataOption constants:

    • xlSortTextAsNumbers. Treats text as numeric data for the sort.

    • xlSortNormaldefault. Sorts numeric and text data separately.

  • DataOption3
    Type: Microsoft.Office.Interop.Excel.XlSortDataOption

    Optional XlSortDataOption. Specifies how to sort text in Key 3. Cannot be used when sorting PivotTable reports. Can be one of the following XlSortDataOption constants:

    • xlSortTextAsNumbers. Treats text numeric data for the sort.

    • xlSortNormaldefault. Sorts numeric and text data separately.

Return Value

Type: System.Object

Remarks

If no arguments are defined with the SortSpecial method, Microsoft Excel will sort the selection, chosen to be sorted, in ascending order.

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace