AT_TreeFortConsulting
New Member
- Joined
- Aug 3, 2021
- Messages
- 14
- Office Version
- 2016
- Platform
- Windows
Hi all,
I created a macro to clear all filters in a table, but if the filters are already cleared and I click the button, I get a Run-time error '1004': ShowAllData method of Worksheet class failed. Is there a way to have it just show a message that the table is already cleared of filters without getting an error?
The VBA is below:
Sub clear_all_filter()
'
' clear_all_filter Macro
'
'
Range("tbl_daily_tracker[[#Headers],[Activity]]").Select
ActiveSheet.ShowAllData
Selection.End(xlToLeft).Select
Selection.End(xlDown).Select
End Sub
I created a macro to clear all filters in a table, but if the filters are already cleared and I click the button, I get a Run-time error '1004': ShowAllData method of Worksheet class failed. Is there a way to have it just show a message that the table is already cleared of filters without getting an error?
The VBA is below:
Sub clear_all_filter()
'
' clear_all_filter Macro
'
'
Range("tbl_daily_tracker[[#Headers],[Activity]]").Select
ActiveSheet.ShowAllData
Selection.End(xlToLeft).Select
Selection.End(xlDown).Select
End Sub