gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,338
- Office Version
- 365
- Platform
- Windows
I have been using the below code to clear filters. But this only works if something is being filtered first, If nothing is filtered and this code is ran, the user gets an error.
Is there another way to do this to avoid the error message? Maybe a way to check if anything is filtered first. Or do you suggest exiting the code on error (which would get difficult because I want to add additional steps to this code - so in the end the code will be doing more than just clearing the cell and filters.
It errors on: ActiveSheet.ShowAllData
Thanks in advance for the help
Is there another way to do this to avoid the error message? Maybe a way to check if anything is filtered first. Or do you suggest exiting the code on error (which would get difficult because I want to add additional steps to this code - so in the end the code will be doing more than just clearing the cell and filters.
It errors on: ActiveSheet.ShowAllData
Thanks in advance for the help
Code:
Sub ClearTemplat()
'
'Step 1
''' Clear Any Filters
Sheets("Step 1").Select
Range("D13").Select
Selection.ClearContents
Sheets("Step 1").Select
Range("D15").Select
ActiveSheet.ShowAllData
End Sub