Filtering Data - Contains formula

ptaylor

New Member
Joined
Jan 21, 2009
Messages
49
I have a list of internet search keywords and I want to filter out ones that have state or city in the keyword string. Is there any way to write a formula that references a list of states/cites and if any of state/city keywords appear in a keyword to have the referenced keyword appear in a cell?
Below example does not show a reference list of state/cities:

Keyword StringFormula
1031 exchange properties available in texastexas
1031 exchange facilitator washington statewashinton
1031 exchange california primary residencecalifornia
1031 exchange rules california real estatecalifornia
1031 exchange rules real estate californiacalifornia

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
There's probably a way to do this with array formulas, but those are not my strong suit.

However, here is a quick and dirty custom formula you can use if you like:

Code:
Function searchMultiple(searchCell As Range, keyWordRange As Range)
    searchMultiple = "NO KEYWORDS FOUND"
    
    Dim searchString As String: searchString = searchCell(1, 1).Value
    Dim keyWordArr: keyWordArr = keyWordRange
    




    For i = LBound(keyWordArr, 1) To UBound(keyWordArr, 1)
        For q = LBound(keyWordArr, 2) To UBound(keyWordArr, 2)
   
        If keyWordArr(i, q) <> "" And InStr(1, searchString, keyWordArr(i, q), vbTextCompare) <> 0 Then
            searchMultiple = keyWordArr(i, q)
            Exit Function
        End If
        Next q
    Next i


    
End Function

Add the code to a module in the workbook, and then use the formula would be =searchMultiple(cellAddress-withSearchString, rangeAddressOfKeyWords)

It is set just return the first keyword it finds. Keywords are not case sensitive.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top