nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
I am trying to build this macro that will clear all contents off a Worksheet, about half the time when its run there is a filter in place. So I put this code in and figured it would work, but when a filter is not in place, it fails. How can i tell the macro to filter if theres a filter, but skip that step if there isnt?
VBA Code:
Sub clearcontents()
Worksheets("Data").ShowAllData
Worksheets("Data").Cells.Clear
Worksheets("Index").Select
End Sub