目标:我正在寻找一个可以根据一列中的单元格条件删除多行的宏,但我希望宏在每次运行时都要求一个值,而不是在代码中包含一个设定值。到目前为止,我在网上找到的每个代码要么不起作用,要么只编码一个值。
我正在使用 excel 2003
这是我发现的适用于我的目的的一个代码。但我想以某种方式对其进行编辑,以便提示用户输入某个数字,而不是一遍又一遍地使用相同的数字。
Sub Delete_Rows()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A2:J707"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "201" _
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub