清除工作簿关闭的过滤器

时间:2017-02-19 03:29:21

标签: excel-vba vba excel

我想在关闭时添加一个函数来清除工作簿上的所有过滤器(所有工作表)..我已经有了这个子,有人可以帮我编写脚本以包含过滤器清除吗?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sht As Worksheet, csheet As Worksheet
Application.ScreenUpdating = False
Set csheet = ActiveSheet
For Each sht In ActiveWorkbook.Worksheets
  If sht.Visible Then
    sht.Activate
    Range("A1").Select
    ActiveWindow.ScrollRow = 1
    ActiveWindow.ScrollColumn = 1
  End If
Next sht
csheet.Activate
Application.ScreenUpdating = True
End Sub

0 个答案:

没有答案