使用数组作为自动筛选条件

我有下面的代码将删除基于列I中的条件的行:

Sub Strip() Dim rng As Range With ActiveSheet .Columns("I").AutoFilter Field:=1, Criteria1:="=70-79%", VisibleDropDown:=False Set rng = .AutoFilter.Range End With If rng.Columns("I").SpecialCells(xlCellTypeVisible).Count - 1 > 0 Then Application.DisplayAlerts = False rng.Offset(1, 0).SpecialCells(xlCellTypeVisible).Delete Application.DisplayAlerts = True End If rng.AutoFilter End Sub 

我有大约100不同的标准,我想以这种方式采取行动。 我宁愿不必重复这个代码100次,所以任何人都可以告诉我如何以数组的forms进行编码? 我尝试了各种方法,但似乎无法得到它的工作。

使用

 .Columns("I").AutoFilter Field:=1, Criteria1:=MyArray, Operator:=xlFilterValues 

其中MyArray是一个string数组

 Dim MyArray(1 To 4) As String MyArray(1) = "This" MyArray(2) = "is" MyArray(3) = "an" MyArray(4) = "array" ' '~~> Rest of code ' .Columns("I").AutoFilter Field:=1, Criteria1:=MyArray, Operator:=xlFilterValues ' '~~> Rest of code ' 

截图

在这里输入图像描述