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

[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Desired result or Similar[/TD]
[/TR]
[TR]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]WINFIELD APARMENT PARTNERS LLC[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]CANTERBURY VILLAGE[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]A AFFORDABLE CARPENTRY INC[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]A-AFFORDABLE CARPETING, INC[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]A AFFORDABLE CARPENTRY INC[/TD]
[/TR]
[TR]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]TOWNVIEW APTS FC[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]TOWNVIEW APARTMENTS[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]TOWNVIEW AP[/TD]
[/TR]
[TR]
[TD]

<tbody>
[TD="width: 461"] THE BLUE HERON GOLF COURSE[/TD]

</tbody>
[/TD]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD="width: 461"]THE BLUE HERON BAR & GRILL[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 461"]
<tbody>[TR]
[TD]THE BLUE HERON[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]Edwards, Anthony, Mark[/TD]
[TD]Mark Edwards[/TD]
[TD]Edwards Mark[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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