0

I am working in an Excel file. My code removes the filters from every worksheet.

The process is long and Excel freezes.

Sub Auto_Open()
    Dim xWs As Worksheet
    For Each Wks In ThisWorkbook.Worksheets
    On Error Resume Next
    If Wks.AutoFilterMode Then
        Wks.AutoFilterMode = False
    End If
    Next Wks
End Sub

Edit:

Sub Auto_Open()
    Application.Calculation = xlManual 'added this line which really sepd it up
    Dim xWs As Worksheet
    For Each Wks In ThisWorkbook.Worksheets
    On Error Resume Next
    If Wks.AutoFilterMode Then
        Wks.AutoFilterMode = False
    End If
    Next Wks
    Application.Calculation = xlAutomatic
End Sub
Community
  • 1
  • 1

0 Answers0