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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,224,814
Messages
6,181,121
Members
453,021
Latest member
Justyna P

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