我正在使用此VBA代码在特定的时间间隔刷新我的整个工作簿。 (thanks to this thread)
如您所见,当前设置为每60分钟刷新一次。
Public RunWhen As Double
Public Const cRunIntervalMinutes = 60
Public Const cRunWhat = "Workbook_RefreshAll"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, cRunIntervalMinutes, 0)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub
Sub Workbook_RefreshAll()
Application.CalculateFullRebuild
ActiveWorkbook.RefreshAll
Call StartTimer
End Sub
该代码很好用,但是我希望它也可以做一件事:
我希望“清除”(不禁用或关闭)自动过滤器,如下面的屏幕抓图所示:
在此先感谢您的帮助。
欢呼
答案 0 :(得分:0)
这应该可以解决问题。当然,如果您愿意,也可以只一张纸做。
Sub Workbook_RefreshAll()
Dim sh As Worksheet
Application.CalculateFullRebuild
ActiveWorkbook.RefreshAll
For Each sh In ActiveWorkbook.Worksheets
If Not (sh.AutoFilter Is Nothing) Then sh.AutoFilter.ShowAllData
Next sh
Call StartTimer
End Sub