我尝试在此网站上进行搜索,但我真的不知道我在寻找什么。我有下面的宏,它工作正常(从本网站取),但我想为其添加更多值以进行检查和删除。在寻找和删除“ AGGF”的地方,我想搜索并删除其他几个词。我可以以某种方式在AGGF之后使用'OR'来做到这一点吗?
Sub AUMReport()
'
' AUMReport Macro
' Dim lRow As Long
Dim iCntr As Long
lRow = 390
For iCntr = lRow To 1 Step -1
If Cells(iCntr, 1).Value = "AGGF" Then
Rows(iCntr).Delete
End If
Next
'
End Sub
答案 0 :(得分:0)
使用Select Case
代替If Then
:
Sub AUMReport()
'
' AUMReport Macro
Dim lRow As Long
Dim iCntr As Long
lRow = 390
For iCntr = lRow To 1 Step -1
Select Case Cells(iCntr, 1).Value
Case "my-first-value", "my-second-value", "my-third-value", "my-etc"
Rows(iCntr).Delete
End Select
Next
'
End Sub