Vba Sorting In Excel 97-2003 Versus 2007 And Above
Rate this:
(3/5 from 1 vote)
The 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