我正在尝试使用VBA,以便根据同一行的单元格的近似内容删除整行。我找到了这个确切的内容:
Sub DeleteRowBasedOnOwner()
Dim RowToTest As Long
For RowToTest = Cells(Rows.Count, 5).End(xlUp).Row To 2 Step -1
With Cells(RowToTest, 5)
If .Value = "John" _
Or .Value = "Jerry" _
Or .Value = "Steve" _
Or .Value = "Robert" _
Or .Value = "Sarah" _
Or .Value = "Leonard" _
Or .Value = "Darryl" _
Or .Value = "Mike" _
Or .Value = "Martin" _
Then _
Rows(RowToTest).EntireRow.Delete
End With
Next RowToTest
End Sub
然而,通配符似乎不在这里工作。例如,我尝试过:
If .Value = "Jo*" _
Or .Value = "*err*" _
但这不起作用。我希望有人能帮助我。
答案 0 :(得分:2)
您可以使用“like”代替“=”。
If .Value like "Jo*" _
Or .Value like "*err*" _