首页 文章

用于更新自动过滤器而无需重新应用的VBA代码

提问于
浏览
1

使用VBA更新表时,有没有办法刷新自动过滤器而无需手动重新应用它?比如,我在A1中有一个值作为表1第1列的过滤器 . 当我清除A1中的内容时,VBA是否可以自动清除第1列中的过滤器而不重新执行代码?或者,如果我更新A1的值,是否还有一种方法可以自动更新column1的过滤器?

我试过了

Sub Name()
ActiveSheet.AutoFilter.ApplyFilter
End Sub

Sub Name(ByVal Target As Range)
Sheets("Sheet1").AutoFilter.ApplyFilter
End Sub

Sub Name(ByVal Target As Range)
With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table1")
     .AutoFilter.ApplyFilter
End With
End Sub

来自各方面 . 我确保代码嵌入在与过滤器模块相同的工作表中,但我似乎仍然做错了...任何帮助将不胜感激!

链接到来源:

https://www.extendoffice.com/documents/excel/4180-excel-refresh-filter-automatically.html https://superuser.com/questions/1004207/macro-for-reapply-filter-on-excel-2016 https://superuser.com/questions/249758/how-to-i-auto-refresh-an-excel-auto-filter-when-data-is-changed

1 回答

相关问题