Export (0) Print
Expand All
3 out of 17 rated this helpful - Rate this topic

Range.Sort Method

Office 2007
Sorts a range of values.

Syntax

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

expression   A variable that represents a Range object.

Parameters

NameRequired/OptionalData TypeDescription
Key1OptionalVariantSpecifies the first sort field, either as a range name (String) or Range object; determines the values to be sorted.
Order1OptionalXlSortOrderDetermines the sort order for the values specified in Key1.
Key2OptionalVariantSecond sort field; cannot be used when sorting a pivot table.
TypeOptionalVariantSpecified which elements are to be sorted.
Order2OptionalXlSortOrderDetermines the sort order for the values specified in Key2.
Key3OptionalVariantThird sort field; cannot be used when sorting a pivot table.
Order3OptionalXlSortOrderDetermines the sort order for the values specified in Key3.
HeaderOptionalXlYesNoGuessSpecifies whether the first row contains header information. xlNo is the default value; specify xlGuess if you want Excel to attempt to determine the header.
OrderCustomOptionalVariantSpecifies a one-based integer offset into the list of custom sort orders.
MatchCaseOptionalVariantSet to True to perform a case-sensitive sort, False to perform non-case sensitive sort; cannot be used with pivot tables.
OrientationOptionalXlSortOrientationSpecifies if the sort should be in acending or decending order.
SortMethodOptionalXlSortMethodSpecifies the sort method.
DataOption1OptionalXlSortDataOptionSpecifies how to sort text in the range specified in Key1; does not apply to pivot table sorting.
DataOption2OptionalXlSortDataOptionSpecifies how to sort text in the range specified in Key2; does not apply to pivot table sorting.
DataOption3OptionalXlSortDataOptionSpecifies how to sort text in the range specified in Key3; does not apply to pivot table sorting.

Return Value
Variant

Reference
Example of Using Range.SortSorting Multiple Columns in a Range




Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.