NamedRange::SortSpecial Method (XlSortMethod, Object^, XlSortOrder, Object^, Object^, XlSortOrder, Object^, XlSortOrder, XlYesNoGuess, Object^, Object^, XlSortOrientation, XlSortDataOption, XlSortDataOption, XlSortDataOption)

 

Uses East Asian sorting methods to sort the NamedRange control. For example, Japanese sorts in the order of the Kana syllabary. For more information, see the parameters list.

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

Object^ SortSpecial(
	XlSortMethod SortMethod = XlSortMethod::xlPinYin,
	Object^ Key1,
	XlSortOrder Order1 = XlSortOrder::xlAscending,
	Object^ Type,
	Object^ Key2,
	XlSortOrder Order2 = XlSortOrder::xlAscending,
	Object^ Key3,
	XlSortOrder Order3 = XlSortOrder::xlAscending,
	XlYesNoGuess Header = XlYesNoGuess::xlNo,
	Object^ OrderCustom,
	Object^ MatchCase,
	XlSortOrientation Orientation = XlSortOrientation::xlSortRows,
	XlSortDataOption DataOption1 = XlSortDataOption::xlSortNormal,
	XlSortDataOption DataOption2 = XlSortDataOption::xlSortNormal,
	XlSortDataOption DataOption3 = XlSortDataOption::xlSortNormal
)

Parameters

SortMethod
Type: Microsoft.Office.Interop.Excel::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 have selected or installed.

Can be one of the following XlSortMethod values:

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

xlPinYin (default). Phonetic Chinese sort order for characters.

Key1
Type: System::Object^

The first sort field, as either text (a range name) or a Microsoft.Office.Interop.Excel::Range object ("Dept" or Cells(1, 1), for example).

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

The sort order for the field or range specified in Key1.

Can be one of the following XlSortOrder values:

xlDescending. Sorts Key1 in descending order.

xlAscending (default). Sorts Key1 in ascending order.

Type
Type: System::Object^

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

Key2
Type: System::Object^

The second sort field, as either text (a range name) or a Microsoft.Office.Interop.Excel::Range object. If you omit this argument, there is no second sort field. Cannot be used when sorting PivotTable reports.

Order2
Type: Microsoft.Office.Interop.Excel::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 values:

xlDescending. Sorts Key2 in descending order.

xlAscending (default). Sorts Key2 in ascending order.

Key3
Type: System::Object^

The third sort field, as either text (a range name) or a Microsoft.Office.Interop.Excel::Range object. If you omit this argument, there is no third sort field. Cannot be used when sorting PivotTable reports.

Order3
Type: Microsoft.Office.Interop.Excel::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 values:

xlDescending. Sorts Key3 in descending order.

xlAscending (default). Sorts Key3 in ascending order.

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

Specifies whether or not the first row contains headers. Cannot be used when sorting PivotTable reports.

Can be one of the following XlYesNoGuess values:

xlGuess. Lets Microsoft Office Excel determine whether there is a header, and to determine where it is, if there is one.

xlNo (default). The entire range should be sorted.

xlYes. The entire range should not be sorted.

OrderCustom
Type: System::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^

true to do a case-sensitive sort; false to do a sort that is not case sensitive. Cannot be used when sorting PivotTable reports.

Orientation
Type: Microsoft.Office.Interop.Excel::XlSortOrientation

The sort orientation.

Can be one of the following XlSortOrientation values:

xlSortRows (default). The sort is done by row.

xlSortColumns. The sort is done by column.

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

Specifies how to sort text in key1. Cannot be used when sorting PivotTable reports.

Can be one of the following XlSortDataOption values:

xlSortTextAsNumbers. Treats text as numeric data for the sort.

xlSortNormal (default). Sorts numeric and text data separately.

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

Specifies how to sort text in key2. Cannot be used when sorting PivotTable reports.

Can be one of the following XlSortDataOption values:

xlSortTextAsNumbers. Treats text as numeric data for the sort.

xlSortNormal (default). Sorts numeric and text data separately.

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

Specifies how to sort text in key3. Cannot be used when sorting PivotTable reports.

Can be one of the following XlSortDataOption values:

xlSortTextAsNumbers. Treats text as numeric data for the sort.

xlSortNormal (default). Sorts numeric and text data separately.

Return Value

Type: System::Object^

If no arguments are defined with this method, Microsoft Office Excel sorts the selection in ascending order.

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the SortSpecial method to sort a NamedRange using Pin Yin (phonetic Chinese sort order for characters). To sort Chinese characters, this example assumes the user has Chinese language support for Microsoft Office Excel. Excel will default to sorting the NamedRange by value if the user does not have Chinese language support.

This example is for a document-level customization.

No code example is currently available or this language may not be supported.
Return to top
Show: