这样你就可以去了该数组里面与要检查里面的数据值/字符串:
Sub DeleteRows()
Dim c As Range
Dim i
Dim r
Dim theValues(1 To 5)
Dim SrchRng As Range
theValues(1) = "1231"
theValues(2) = "1232"
theValues(3) = "1233"
theValues(4) = "1234"
theValues(5) = "1235"
r = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set SrchRng = Range(Cells(1, 1), Cells(r, 1))
For Each i In theValues
Do
Set c = SrchRng.Find(i, LookIn:=xlValues, LookAt:=xlWhole)
'see the ", LookAt:=xlWhole" added, this way you can find just the Whole values.
If Not c Is Nothing Then c.EntireRow.Delete
Loop While Not c Is Nothing
Next i
End Sub
编辑#1 当您在留言问,请参阅编辑以便:查看仅显示完整值的数据(您可以查找91
而不是910
或1891
),然后继承人是我的版本,如果要将值放入工作表中的某个范围内,则可以添加任何值被发现。
Sub DeleteRows()
Dim c As Range
Dim i
Dim r
Dim rng As Range
Dim a
Dim theValues()
Dim SrchRng As Range
r = Range("T1").End(xlDown).Row
Set rng = Range("T1", Cells(r, 20))
For a = 1 To rng.Count 'in this range i store the values
ReDim Preserve theValues(1 To a)
theValues(a) = rng(a)
Next a
r = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set SrchRng = Range(Cells(1, 1), Cells(r, 1))
For Each i In theValues
Do
Set c = SrchRng.Find(i, LookIn:=xlFormulas, LookAt:=xlWhole)
If Not c Is Nothing Then c.EntireRow.Delete
Loop While Not c Is Nothing
Next i
End Sub
检查我的anser并编辑。 –