This documentation is archived and is not being maintained.

Range.SortSpecial Method

Office 2007
Uses East Asian sorting methods to sort the range, 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.

Syntax

expression.SortSpecial(SortMethod, Key1, Order1, Type, Key2, Order2, Key3, Order3, Header, OrderCustom, MatchCase, Orientation, DataOption1, DataOption2, DataOption3)

expression   A variable that represents a Range object.

Parameters

NameRequired/OptionalData TypeDescription
SortMethodOptionalXlSortMethodThe 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.
Key1OptionalVariantThe first sort field, as either text (a PivotTable field or range name) or a Range object ("Dept" or Cells(1, 1), for example).
Order1OptionalXlSortOrderThe sort order for the field or range specified in the Key1 argument.
TypeOptionalVariantSpecifies which elements are to be sorted. Use this argument only when sorting PivotTable reports.
Key2OptionalVariantThe 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.
Order2OptionalXlSortOrderThe sort order for the field or range specified in the Key2 argument. Cannot be used when sorting PivotTable reports.
Key3OptionalVariantThe 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.
Order3OptionalXlSortOrderThe sort order for the field or range specified in the Key3 argument. Cannot be used when sorting PivotTable reports.
HeaderOptionalXlYesNoGuessSpecifies whether or not the first row contains headers. Cannot be used when sorting PivotTable reports.
OrderCustomOptionalVariantThis argument is a one-based integer offset to the list of custom sort orders. If you omit OrderCustom, (normal sort order) is used.
MatchCaseOptionalVariantTrue to do a case-sensitive sort; False to do a sort that’s not case sensitive. Cannot be used when sorting PivotTable reports.
OrientationOptionalXlSortOrientationThe sort orientation.
DataOption1OptionalXlSortDataOptionSpecifies how to sort text in Key1. Cannot be used when sorting PivotTable reports.
DataOption2OptionalXlSortDataOptionSpecifies how to sort text in Key2. Cannot be used when sorting PivotTable reports.
DataOption3OptionalXlSortDataOptionSpecifies how to sort text in Key3. Cannot be used when sorting PivotTable reports.

Return Value
Variant

Remarks

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

Example

This example sorts the range A1:A5 using Pin Yin (phonetic Chinese sort order for characters). In order to sort Chinese characters, this example assumes the user has Chinese language support for Microsoft Excel. Even without Chinese language support, Excel will default to sorting any numbers placed within the specified range for this example. This example assumes there is data contained in the range A1:A5.

Visual Basic for Applications
Sub SpecialSort()

    Application.Range("A1:A5").SortSpecial SortMethod:=xlPinYin

End Sub



Show: