Key Word Macro or formula

Welsh Mark3

Board Regular
Joined
Apr 7, 2014
Messages
164
Office Version
  1. 365
Is there a Macro or formula that will highlight or allow me to identify if a keyword exists in column A and B? I am looking to produce something in Column C to quickly match company names without doing it manually. Any solution will be gratefully received

Column AColumn BDesired result or Similar
WINFIELD APARMENT PARTNERS LLC

<tbody>
</tbody>
CANTERBURY VILLAGE

<tbody>
</tbody>
A AFFORDABLE CARPENTRY INC

<tbody>
</tbody>
A-AFFORDABLE CARPETING, INC

<tbody>
</tbody>
A AFFORDABLE CARPENTRY INC
TOWNVIEW APTS FC

<tbody>
</tbody>
TOWNVIEW APARTMENTS

<tbody>
</tbody>
TOWNVIEW AP
THE BLUE HERON GOLF COURSE

<tbody>
</tbody>
THE BLUE HERON BAR & GRILL

<tbody>
</tbody>
THE BLUE HERON

<tbody>
</tbody>
Edwards, Anthony, MarkMark EdwardsEdwards Mark

<tbody>
</tbody>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Welsh Mark3,

The following might get you started...

Code:
Sub keyWord_1063727()
Dim r As Long, c As Long, i As Long, j As Long
Dim arr As Variant, arrA As Variant, arrB As Variant
Dim keyWord As String

arr = ActiveSheet.UsedRange.Offset(1, 0)
For r = 1 To UBound(arr)
    arrA = Split(arr(r, 1), " ")
    arrB = Split(arr(r, 2), " ")
    keyWord = ""
    For i = LBound(arrA) To UBound(arrA)
        For j = LBound(arrB) To UBound(arrB)
            If InStr(arr(r, 1), arrB(j)) > 0 And InStr(keyWord, arrB(j)) = 0 Then
                If keyWord <> "" Then
                    keyWord = keyWord & " " & arrB(j)
                Else
                    keyWord = arrB(j)
                End If
            End If
            If InStr(arr(r, 2), arrA(i)) > 0 And InStr(keyWord, arrA(i)) = 0 Then
                If keyWord <> "" Then
                    keyWord = keyWord & " " & arrA(i)
                Else
                    keyWord = arrA(i)
                End If
            End If
        Next j
    Next i
    arr(r, 3) = keyWord
Next r
ActiveSheet.UsedRange.Offset(1, 0).Value = arr
MsgBox "The dishes are done, dude!"
End Sub

The code matches whole words, not partial words.

Cheers,

tonyyy
 
Upvote 0
Is there a Macro or formula that will highlight or allow me to identify if a keyword exists in column A and B?
It is a massive thread to look through (and may be best looking from the end backwards?) but this may be of use to you.
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,995
Members
449,480
Latest member
yesitisasport

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