I have a public following sub in my code as shown below:
Public Sub ResetFilters(ByRef tbl As ListObject)
With tbl
'// If Filter Arrows are OFF - turns them on
'// If Filter Arrows are ON - turns them off and resets filter
.Range.AutoFilter
'// Always turns filter arrows to on and sorts table by first field
.Range.AutoFilter Field:=1
End With
End Sub
As you can See I make use of Excel Tables (ListObjects in vba speak) so I pass the reference into the sub, and it is supposed to reset the table to an unfiltered state. It works fine on a PC with Excel 2007 but fails on Excel 2011 on a Mac with:
Method ‘Autofilter’ of Object ‘Range’ failed
The following link for Excel 2011 VBA Reference shows the AutoFilter Method of the Range object and it matches what I can see in the references for Excel 2007 VBA References.
So can anyone see why this is failing?
It doesnt seem there have been alot of people jumping at this question… At any rate, if anyone else is interested, I think I found a workaround using the
ListObject.ShowAutoFilterproperty. It is a read/write boolean property and when turned off, it will reset the filters in the ListObject. It has the added bonus of working on both Excel 2011 for Mac and Excel 2007 (and 2010 for that matter) on PC’s.