Excel VBA @SQL String filter Multiple LIKE Conditi

2019-01-20 14:06发布

问题:

This code works as intended but I also need to exclude Autoreplies and some other strings in a subject line. I need to know if it's possible to add 2 or 3 more Likes.

I tried And and Or conditions but I'm getting a parse error.

This code below works. I just need to add another string condition after undeliverable. " Like '%Automatic reply%'".

Filter = "@SQL=" & " Not " & _
             "urn:schemas:httpmail:subject" & "" & _
             " Like '%undeliverable%'"

thanks.

回答1:

OR Should work, The following Example have either %undeliverable% Or %Automatic reply%


Filter = "@SQL=" & " Not (urn:schemas:httpmail:subject" & _
                   " Like '%undeliverable%'  Or " & _
                         "urn:schemas:httpmail:subject" & _
                   " Like '%Automatic reply%')"

To Add one more Filter

Filter = "@SQL=" & " Not (urn:schemas:httpmail:subject" & _
                   " Like '%undeliverable%'  Or " & _
                         "urn:schemas:httpmail:subject" & _
                   " Like '%Automatic reply%' Or " & _
                         "urn:schemas:httpmail:subject" & _
                   " Like '%Bla Bla%')"