Sub shanchu()
Dim strinput$, arr
Dim i As Long
Dim j As Long
Dim k As Long
Dim z As Long
'matchlabel = False
strinput = Application.InputBox("请输入需要保留的所有穴号,穴号之间必须用空格隔开! ", "提示:") '需要保留行A列的标号
j = Cells(Rows.Count, 1).End(3).Row '获取A列最后一行行号
k = Application.InputBox("请输入尺寸起始行的行号:", "提示:", 1) '设置终止运行代码行(从下往上运行)
arr = Split(strinput, " ") '用空格提取并定义组数
For z = j To k Step -1 '步长为-1(从下往上)
For i = 0 To UBound(arr) '遍历每个组数
If arr(i) = Cells(z, 1) Then '判定组数是否包含单元格中的值
Else
Cells(z, 1).EntireRow.Delete '删除单元格所在的行
End If
Next i
'退出循环
Next z
End Sub

Dim strinput$, arr
Dim i As Long
Dim j As Long
Dim k As Long
Dim z As Long
'matchlabel = False
strinput = Application.InputBox("请输入需要保留的所有穴号,穴号之间必须用空格隔开! ", "提示:") '需要保留行A列的标号
j = Cells(Rows.Count, 1).End(3).Row '获取A列最后一行行号
k = Application.InputBox("请输入尺寸起始行的行号:", "提示:", 1) '设置终止运行代码行(从下往上运行)
arr = Split(strinput, " ") '用空格提取并定义组数
For z = j To k Step -1 '步长为-1(从下往上)
For i = 0 To UBound(arr) '遍历每个组数
If arr(i) = Cells(z, 1) Then '判定组数是否包含单元格中的值
Else
Cells(z, 1).EntireRow.Delete '删除单元格所在的行
End If
Next i
'退出循环
Next z
End Sub


