Home > Forum Home > Excel Portfolio Optimization Template > Run time error 438 > VBA Sorting in Excel 97-2003 versus 2007 and above Share

VBA Sorting in Excel 97-2003 versus 2007 and above

Excel Help for Vba Sorting In Excel 97-2003 Versus 2007 And Above in Excel Portfolio Optimization Template


Forum TopicLogin

Vba Sorting In Excel 97-2003 Versus 2007 And Above

Rate this:
(3/5 from 1 vote)
ShockedThe sorting functionality is more advanced in Excel 2007 and 2010 than Excel 2003 and prior.  For Excel 97-2003 simple sorting cannot be cleared as the data order is simply changed and the method is not stored in memory.

A filter can however be both set and cleared. To set a filter, sort on a column and then clear the filter, the following code (with comments) can be used.

VBA Code:
'Select the region
Sheets("Value of Incentives by Cust").Select
Range("O19:U80").Select

'Create a filter on the selected region
Selection.AutoFilter

'Sort a column - add more with Key2 etc
Range("U19:U80").Sort Key1:=Range("U19"), Order1:=xlDescending, Header:= _
        xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal

'Clear the filter (note that this is the same as setting a filter so if one exists it will clear it and if not it will add one).
Selection.AutoFilter
 Excel Business Forums Administrator
 Posted by on
 
View Full Post

Find relevant Excel templates and add-ins for VBA Sorting in Excel 97-2003 versus 2007 and above in the