[英]VBA if cell contain specific text then delete entire row
I'm looking for a VBA code that search a list of string like [bana, app, ora] and delete the entire row if the cells contains this.我正在寻找一个 VBA 代码,它可以搜索像[bana, app, ora]这样的字符串列表,如果单元格包含它,则删除整行。
For example: If C6 contains the word "apple" or "Application" then the row 6 will be deleted If H9 contains the word "Orage" or "orange" or "oracle" then row 9 will be deleted例如:如果 C6 包含单词“apple”或“Application” ,则第 6 行将被删除 如果 H9 包含单词“Orage”或“orange”或“oracle” ,则第 9 行将被删除
Every code I found on internet is for the situation when the entire cell contains the specified string but it's not what I'm looking for.我在互联网上找到的每个代码都是针对整个单元格包含指定字符串的情况,但这不是我想要的。
Thank you so much for you're help!非常感谢你的帮助!
Use instr()
:使用instr()
:
Sub deleteTheWholeRow()
For Each rngCell in Sheets("Somesheet").Range("A1:A50")
If instr(1, "apple", rngCell.value) Then
rngCell.entireRow.Delete
End If
Next rngCell
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.