Click to Rate and Give Feedback
MSDN
MSDN Library
Office Development
Excel 2007
Range Object
Methods
 Sort Method

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Range.Sort Method
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




Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker