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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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