blacklist of words - find if cells have the value

in sheet 2, i have a list of 200 words

i sheet 1 i have 70k rows , col A has sentences

i need vba code that looks at the 200 words and deletse and row that contains a word from sheet2

thx!
finnstoneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Sub macro()
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
Set regex = CreateObject("VBScript.RegExp")

Set rngWrds = Range(sh2.Range("A1"), sh2.Range("A" & Rows.Count).End(xlUp))
aRng = WorksheetFunction.Index(WorksheetFunction.Transpose(rngWrds), 1, 0)
strRng = Join(aRng, "|")
    With regex
        .Global = False
        .MultiLine = False
        .IgnoreCase = True
        .Pattern = "\b(" & strRng & ")+\b"
    End With
For Idx = sh1.Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
    If regex.Test(sh1.Range("A" & Idx)) Then
        sh1.Range("A" & Idx).EntireRow.Delete
    End If
Next
End Sub

Open in new window

Regards
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
finnstoneAuthor Commented:
aRng - throws error
0
Rgonzo1971Commented:
Could you send a dummy?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

finnstoneAuthor Commented:
attachgyed
Book1.xlsm
0
Rgonzo1971Commented:
the list must have at least 2 words even if the same
0
aikimarkCommented:
@finnstone

How's the performance of the .Test() method?  If you want to play with performance, you might try sorting the entries by frequency.
Here's a routine that will return a dictionary of the 5000 most frequent English words.
Function WordFreq() As Object
    Dim dicWords As Object
    
    Dim oRE As Object
    Dim oMatches As Object
    Dim oM As Object
    
    Dim oXMLHTTP As Object
    Dim strHTML As String
    
    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
    oXMLHTTP.Open "GET", "https://www.wordfrequency.info/free.asp?s=y", False
    oXMLHTTP.Send
    
    Do Until oXMLHTTP.ReadyState = 4
        DoEvents
    Loop
    
    If oXMLHTTP.Status = 200 Then
        strHTML = oXMLHTTP.responsetext
        Set dicWords = CreateObject("scripting.dictionary")
        Set oRE = CreateObject("vbscript.regexp")
        oRE.Global = True
        oRE.Pattern = "<tr>\s*<td>(\d+)</td>\s*<td>([^<]+)</td>"
        Set oMatches = oRE.Execute(strHTML)
        For Each oM In oMatches
            If dicWords.exists(oM.submatches(1)) Then
            Else
                dicWords(oM.submatches(1)) = oM.submatches(0)
            End If
        Next
    End If
    
    Set WordFreq = dicWords

End Function

Open in new window

0
finnstoneAuthor Commented:
new one if you can help, opposite this time with a whitelist need
https://www.experts-exchange.com/pendingQuestions/50656/whitelist-of-words.html
need to put a 1 value in column AA where the value in A matches a word in sheet2
0
aikimarkCommented:
That isn't a valid link to an open question
0
finnstoneAuthor Commented:
IT WILL BE PUBLISHED IN 90 MINUTES...
0
finnstoneAuthor Commented:
BUT it exactly what i wrote above and below-

need to put a 1 value in column AA where the value in A matches a word in sheet2
0
finnstoneAuthor Commented:
rgonzo, why is this not working now? it seems to be the particular data set. can you look?
Book1.xlsm
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.