📅  最后修改于: 2022-03-11 14:51:53.663000             🧑  作者: Mango
'this method should not give error "method showalldata of object _worksheet failed"
Sub ClearFiters()
Dim MySheet As Worksheet: Set MySheet = ThisWorkbook.Sheets("MySheet")
Dim MyTableName As String: MyTableName = "MyTable"
MySheet.Activate
MySheet.Range(MyTableName).Select
Dim t As ListObject: Set t = MySheet.ListObjects(MyTableName)
t.Sort.SortFields.Clear
If t.AutoFilter.FilterMode Then
MySheet.ShowAllData
End If
End Sub