简体   繁体   中英

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.

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

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() :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM