Compare 2 columns and one of them has partial value of the other

taleixo

New Member
Joined
Apr 23, 2020
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
I have a macro that compares the column of a table with the column of another (both are extracted from an application), and returns me which values do not exist in both. However, the Table4[MSG_DESCRIPTION] column has a limit of 50 characters, and the Table3[Title] column has 500 characters. I would need that in addition to returning the values that do not exist (as is already done) the macro would also be valid if the partial value of the Table4 column [MSG_DESCRIPTION] exists in the Table3 column [Title]. In formula I had used vlookup with & "*" and it worked, but I would need it in the macro.
Thanks.

VBA Code:
Sub ValoresUnicos()
Dim rngCell As Range
For Each rngCell In Range("Tabela4[MSG_DESCRIPTION]")
    If WorksheetFunction.CountIf(Range("Tabela3[Title]"), rngCell) = 0 Then
        Range("Comparação!C" & Rows.Count).End(xlUp).Offset(1) = rngCell
    End If
Next
For Each rngCell In Range("Tabela3[Title]")
    If WorksheetFunction.CountIf(Range("Tabela4[MSG_DESCRIPTION]"), rngCell) = 0 Then
        Range("Comparação!H" & Rows.Count).End(xlUp).Offset(1) = rngCell
    End If
Next
End Sub
 

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.

Forum statistics

Threads
1,223,879
Messages
6,175,150
Members
452,615
Latest member
bogeys2birdies

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