XL97: Problem Using Sort Method with More Than One Key (229107)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q229107 SYMPTOMS
When you attempt to programmatically sort a range using more than one key, all but the first sort key is ignored. This problem occurs when you call the Sort method using positional arguments, which is common with automation. The problem does not occur if you used named arguments.
CAUSE
According to the Excel type library and the Excel VBA Help file, the Sort method has the following syntax:
Sort ([Key1], [Order1], [Key2], [Type], [Order2], [Key3], [Order3],
[Header], [OrderCustom], [MatchCase], [Orientation], [SortMethod])
The documentation is incorrect: the Key2 and Type arguments are reversed.
The syntax of the Sort method should read as follows:
Sort ([Key1], [Order1], [Type], [Key2], [Order2], [Key3], [Order3],
[Header], [OrderCustom], [MatchCase], [Orientation], [SortMethod])
RESOLUTION
To correct this problem, you can:
- Reverse the order of the Type and Key2 arguments in your code if you are using positional arguments.
-or-
- Use named arguments.
STATUSThis bug was corrected in Microsoft Excel 2000.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbbug kbdtacode kbfix KB229107 |
---|
|