編輯

共用方式為


Range.SortSpecial Method

Definition

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.

public object SortSpecial (Microsoft.Office.Interop.Excel.XlSortMethod SortMethod = Microsoft.Office.Interop.Excel.XlSortMethod.xlPinYin, object Key1, Microsoft.Office.Interop.Excel.XlSortOrder Order1 = Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending, object Type, object Key2, Microsoft.Office.Interop.Excel.XlSortOrder Order2 = Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending, object Key3, Microsoft.Office.Interop.Excel.XlSortOrder Order3 = Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending, Microsoft.Office.Interop.Excel.XlYesNoGuess Header = Microsoft.Office.Interop.Excel.XlYesNoGuess.xlNo, object OrderCustom, object MatchCase, Microsoft.Office.Interop.Excel.XlSortOrientation Orientation = Microsoft.Office.Interop.Excel.XlSortOrientation.xlSortRows, Microsoft.Office.Interop.Excel.XlSortDataOption DataOption1 = Microsoft.Office.Interop.Excel.XlSortDataOption.xlSortNormal, Microsoft.Office.Interop.Excel.XlSortDataOption DataOption2 = Microsoft.Office.Interop.Excel.XlSortDataOption.xlSortNormal, Microsoft.Office.Interop.Excel.XlSortDataOption DataOption3 = Microsoft.Office.Interop.Excel.XlSortDataOption.xlSortNormal);
Public Function SortSpecial (Optional SortMethod As XlSortMethod = Microsoft.Office.Interop.Excel.XlSortMethod.xlPinYin, Optional Key1 As Object, Optional Order1 As XlSortOrder = Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending, Optional Type As Object, Optional Key2 As Object, Optional Order2 As XlSortOrder = Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending, Optional Key3 As Object, Optional Order3 As XlSortOrder = Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending, Optional Header As XlYesNoGuess = Microsoft.Office.Interop.Excel.XlYesNoGuess.xlNo, Optional OrderCustom As Object, Optional MatchCase As Object, Optional Orientation As XlSortOrientation = Microsoft.Office.Interop.Excel.XlSortOrientation.xlSortRows, Optional DataOption1 As XlSortDataOption = Microsoft.Office.Interop.Excel.XlSortDataOption.xlSortNormal, Optional DataOption2 As XlSortDataOption = Microsoft.Office.Interop.Excel.XlSortDataOption.xlSortNormal, Optional DataOption3 As XlSortDataOption = Microsoft.Office.Interop.Excel.XlSortDataOption.xlSortNormal) As Object

Parameters

SortMethod
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
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
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
Object

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

Key2
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
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
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
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
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
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
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.

Orientation
XlSortOrientation

Optional XlSortOrientation. The sort orientation. Can be one of the following XlSortOrientation constants:xlSortRowsdefault. The sort is done by row.xlSortColumns. The sort is done by column.

DataOption1
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
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
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.

Returns

Remarks

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

Applies to