Link to home
Start Free TrialLog in
Avatar of finnstone
finnstone

asked on

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!
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of finnstone
finnstone

ASKER

aRng - throws error
Could you send a dummy?
attachgyed
Book1.xlsm
the list must have at least 2 words even if the same
@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

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
That isn't a valid link to an open question
IT WILL BE PUBLISHED IN 90 MINUTES...
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
rgonzo, why is this not working now? it seems to be the particular data set. can you look?
Book1.xlsm