使用VBA更新表时,是否有方法刷新自动筛选器而无需手动重新应用它?比如说,我在A1中有一个值作为表1第1列的过滤器。当我清除A1中的内容时,VBA是否会自动清除第1列中的过滤器而不重新执行代码?或者,如果我更新A1的值,有没有办法让column1的过滤器自动更新?用于更新自动筛选器而不重新应用的VBA代码
我已经试过
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
寻找到一个['Worksheet_Change()'事件](https://msdn.microsoft.com/en-us/library/office/ff839775.aspx)。 – BruceWayne
我会尽力回复你。谢谢! :) – syang