I need to clear any active filters from the sheet before running a specific macro, this line works just fine if there is an active filter on
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
However, if no filters are selected, it returns an error
Runtime error '1004'; ShowAllData method of Worksheet class failed
I got this code from the answer to this question Excel 2013 VBA Clear all filter filters
However, this question does not explain how to ignore a string if filters are not active.
How to ignore this line if no active filters are currently applied?
EDIT
For example, all column headings were automatically filtered, so if my sheet is filtered "Female", for example, I need to remove this filter before running the macro, however, if the filters were not applied, just run the macro as normal
vba excel-vba excel
Tim wilkinson
source share