whitelist of words

opposite of this one.
https://www.experts-exchange.com/questions/29079746/blacklist-of-words-find-if-cells-have-the-value.html#a42444598

need to put a 1 value in column AA where the value in A matches a word in sheet2
finnstoneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Martin LissOlder than dirtCommented:
Is "AA" the column where you want a "1"?

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("AA" & Idx) = "1"
    End If
Next
End Sub

Open in new window

0

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
Rgonzo1971Commented:
HI,

If you want the count of matched words instead of 1
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 = True
        .MultiLine = True
        .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
        set Mtchs = regex.Execute(sh1.Range("A" & Idx))
        sh1.Range("AA" & Idx) = Mtchs.Count
    End If
Next
End Sub

Open in new window

Regards
0
finnstoneAuthor Commented:
thx!
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Martin LissOlder than dirtCommented:
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 201
0
finnstoneAuthor Commented:
THIS does not seem to be working as intended. please see attached. why are rows getting flagged as meting the white list conditions when they do not have any of the words matching the column in sheet2??!

thanks
whitelist-twitter.xlsm
0
Martin LissOlder than dirtCommented:
An example or two please?
0
finnstoneAuthor Commented:
look at rows 17,18,21 ...none have words that are in sheet2
0
Martin LissOlder than dirtCommented:
Row 17 contains 'technology'  which matches (except for case) Sheet2 row 81.
Row 18 contains 'platform'  which matches (except for case) Sheet2 row 65.
Row 21 contains 'Business'  which matches Sheet2 row 13.
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.