I have filters on 100+ columns on many of my worksheets and I frequently forget to remove the filter when moving to another sheet. Then, when I return to that sheet, I can easily not realise that a filter is already in place, leading to all sorts of problems.
I've been trying to automate removal of filters but it's not working properly. As a first step I currently have the following in the ThisWorkbook module:
I just opened the workbook and 2 filters were still in place. How should I be coding this so that it works as intended? Ultimately I'd like coding that removes the filters every time I move to another sheet, but filter removal on closing the workbook would be OK as a first step.
I've been trying to automate removal of filters but it's not working properly. As a first step I currently have the following in the ThisWorkbook module:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim WS As Worksheet
For Each WS In Worksheets
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Next WS
ThisWorkbook.Save
End Sub