• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Multiple text criteria needs to be included to delete rows that do not match

Anand307

Member
We have VBE code to delete the rows if the cells in column B does not contain specific text characters. However the code that I have is allowing to input only one text criteria at once, I tried to create 3 separate text criteria and then call the modules one after the other, later I got to know this method will not work. Hence please help me to know how to add multiple text criteria in the existing module.

Current criteria is "Total", we need to have two more that is "Today" and "Delete". Please help me to include this in code.
 
Code:
Sub RemoveRows()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    If Not Range("B" & i).Value Like "Total*" Then Rows(i).Delete
Next i
End Sub
 
You can use a formula in a helper column as explained here

Or continue your way like If Not (Test1 Or Test2 Or Test3) Then

As Test1 is Range("B" & i).Value Like "Total*"
so just replace grey part by a condition …
 
Back
Top