According to another thread, you need to check if sheet is in AutoFilterMode? It seems to have done the trick! See "Andy Pope" answer:
http://www.excelforum.com/excel-prog...e-not-set.html
"Your code leaves the autofilter in place when either of the 2 routines runs.
This means next time a routine is run the Autofilter command actually removes the autofilter which is why the clearing of the sort fails.
You need to test for the autofilter being present are applying if not."
Sub AutoFilter()
Range("A83:Q83").Select
Selection.AutoFilter
If Not ActiveSheet.AutoFilterMode Then Selection.AutoFilter
ActiveWorkbook.Worksheets("Portfolio by Week").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Portfolio by Week").AutoFilter.Sort.SortFields.Add _
Key:=Range("L83"), _
SortOn:=xlSortOnValues, _
Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Portfolio by Week").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Bookmarks