EXCEL: Delete row based on keyword in Column B

I have 80,000 rows in my spreadsheet.  I want to delete entire rows where the following words are found anywhere in Column B (not case sensitive)

University
Community
Primary Care
Red Cross
YMCA
Family Services
Hospital
Mental Health Center
Outpatient
Treatment
Medical
County
Church
Outreach
Children's Home
Rehabilitation
Senior

Can someone help me do this?  Thank you!!
arthurh88Asked:
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.

Patrick MatthewsCommented:
In another column, use an array formula like this:

{=MAX(COUNTIF(B2,{"*Red Cross*","*YMCA*"}))}

Do not enter those outer curley braces (but do use the inner ones!), and use Ctrl+Shift+Enter instead of just Enter to finish it off.

Once you apply that column, sort on it, and delete all the rows where that value is greater than zero.

(You'll need to add the additional search terms as well.)
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
Wasim Akram ShaikCommented:
@matthews :good one, i too can use this :), thanks..!!
0
arthurh88Author Commented:
just fantastic
0
krishnakrkcCommented:
Hi,

A VBA approach.

Kris
Sub kTest()
    
    Dim k, a(), i As Long, n As Long, txt As String, r As Range
    Dim Crit, dic   As Object
    
    Set r = Range("b1:b" & Range("b" & Rows.Count).End(xlUp).Row)
    
    Crit = Array("University", "Community", "Primary Care", "Red Cross", "YMCA", "Family Services", _
                "Hospital", "Mental Health Center", "Outpatient", "Treatment", "Medical", "County", _
                "Church", "Outreach", "Children's Home", "Rehabilitation", "Senior")
    
    Set dic = CreateObject("scripting.dictionary")
        dic.comparemode = 1
    
    For i = LBound(Crit) To UBound(Crit)
        dic.Item(Crit(i)) = Empty
    Next
    
    k = r
    ReDim a(1 To 1000)
    For i = UBound(k, 1) To 1 Step -1
        If dic.exists(k(i, 1)) Then
            txt = txt & "," & "a" & i
            If Len(txt) > 245 Then
                n = n + 1
                a(n) = Mid$(txt, 2)
                txt = vbNullString
            End If
        End If
    Next
    If Len(txt) > 1 Then
        n = n + 1
        a(n) = Mid$(txt, 2)
        txt = vbNullString
    End If
    
    If n Then
        Application.ScreenUpdating = False
        With r
            For i = 1 To n
                .Range(CStr(a(i))).EntireRow.Delete
            Next
        End With
    End If
    Application.ScreenUpdating = True
        
End Sub

Open in new window

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
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.