gpt4 book ai didi

vba - 根据该行单元格中的文本删除整行

转载 作者:行者123 更新时间:2023-12-02 19:46:16 30 4
gpt4 key购买 nike

我正在尝试使用 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*" _

但这不起作用。我希望有人能帮助我解决这个问题。

最佳答案

您可以使用“like”代替“=”。

 If .Value like "Jo*" _
Or .Value like "*err*" _

关于vba - 根据该行单元格中的文本删除整行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32560594/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com