[英]Criteria for Autofilter using Array , MS Excel
I've created a module to delete rows using Autofilter and Criteria is Min date,我创建了一个模块来使用 Autofilter 和 Criteria is Min date 删除行,
The problem is AutoFilter doesn't work when I create an array to define criteria.问题是当我创建一个数组来定义条件时,自动筛选不起作用。 Is there anyway to fix this problem.有没有办法解决这个问题。
Sub Delete_Rows()
Dim lo As ListObject
Dim arr As Variant
arr = Sheet4.Range("A2")
Set lo = Sheet1.ListObjects(1)
lo.Range.AutoFilter Field:=2, Criteria1:=arr, Operator:=xlFilterValues
Application.DisplayAlerts = False
lo.DataBodyRange.SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
lo.AutoFilter.ShowAllData
End Sub
Sub Delete_Rows()子 Delete_Rows()
Dim lo As ListObject
Dim arr As Variant
arr = Sheet4.Range("A2").value
Set lo = Sheet1.ListObjects(1)
lo.Range.AutoFilter Field:=2, Criteria1:=">" & Format(arr, "mm/dd/yy"), Operator:=xlFilterValues
Application.DisplayAlerts = False
lo.DataBodyRange.SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
lo.AutoFilter.ShowAllData
End Sub结束子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.