Match data columns to columns million + with scripting dictionary

SamKhem

Board Regular
Joined
Mar 18, 2024
Messages
50
Office Version
  1. 2016
Platform
  1. Windows
Dear Senior member
I would like you to assist as I have 4 columns data 1 to 4 and 4 columns Main 1 to Main 4. Need to matching base on data 1 to data 4 compare with Main1 to Main 4 and get result 1 to result 4 and different 1 to different 4 as sample below.
Thank for support.
Data 1Data 2Data 3Data 4Main 1Main 2Main 3Main 4Match 1Match 2Match 3Match 4Different 1Different 2Different 3Different 4
ABC-2222-123345DEF-2222-123345GHT-2222-123345NBC-2222-123345ABC-0987-89766DEF-0987-89766GHT-0987-89766NBC-0987-89766
ABC-1111-123345DEF-1111-123345GHT-1111-123345NBC-1111-123345ABC-1111-123345DEF-1111-123345GHT-1111-123345NBC-1111-123345
ABC-2222-89765DEF-2222-89765GHT-2222-89765NBC-2222-89765ABC-1285-89771DEF-1285-89771GHT-1285-89771NBC-1285-89771
ABC-0987-89766DEF-0987-89766GHT-0987-89766NBC-0987-89766ABC-2222-123345DEF-2222-123345GHT-2222-123345NBC-2222-123345
ABC-2222-89767DEF-2222-89767GHT-2222-89767NBC-2222-89767ABC-2222-89765DEF-2222-89765GHT-2222-89765NBC-2222-89765
ABC-2222-89768DEF-2222-89768GHT-2222-89768NBC-2222-89768ABC-2222-89767DEF-2222-89767GHT-2222-89767NBC-2222-89767
ABC-2222-89769DEF-2222-89769GHT-2222-89769NBC-2222-89769ABC-2222-89768DEF-2222-89768GHT-2222-89768NBC-2222-89768
ABC-2222-89770DEF-2222-89770GHT-2222-89770NBC-2222-89770ABC-2222-89769DEF-2222-89769GHT-2222-89769NBC-2222-89769
ABC-1285-89771DEF-1285-89771GHT-1285-89771NBC-1285-89771ABC-2222-89770DEF-2222-89770GHT-2222-89770NBC-2222-89770
ABC-2222-89772DEF-2222-89772GHT-2222-89772NBC-2222-89772ABC-2222-89772DEF-2222-89772GHT-2222-89772NBC-2222-89772
ABC-2222-89773DEF-2222-89773GHT-2222-89773NBC-2222-89773ABC-2222-89773DEF-2222-89773GHT-2222-89773NBC-2222-89773
ABC-2222-89774DEF-2222-89774GHT-2222-89774NBC-2222-89774ABC-2222-89774DEF-2222-89774GHT-2222-89774NBC-2222-89774
ABC-2222-89775DEF-2222-89775GHT-2222-89775NBC-2222-89775ABC-2222-89775DEF-2222-89775GHT-2222-89775NBC-2222-89775
ABC-2222-89776DEF-2222-89776GHT-2222-89776NBC-2222-89776ABC-2222-89776DEF-2222-89776GHT-2222-89776NBC-2222-89776
ABC-2222-89777DEF-2222-89777GHT-2222-89777NBC-2222-89777ABC-2222-89777DEF-2222-89777GHT-2222-89777NBC-2222-89777
ABC-2222-89778DEF-2222-89778GHT-2222-89778NBC-2222-89778ABC-2222-89778DEF-2222-89778GHT-2222-89778NBC-2222-89778
ABC-2222-89779DEF-2222-89779GHT-2222-89779NBC-2222-89779ABC-2222-89779DEF-2222-89779GHT-2222-89779NBC-2222-89779
ABC-2222-89780DEF-2222-89780GHT-2222-89780NBC-2222-89780ABC-2222-89780DEF-2222-89780GHT-2222-89780NBC-2222-89780
ABC-2222-89781DEF-2222-89781GHT-2222-89781NBC-2222-89781ABC-2222-89781DEF-2222-89781GHT-2222-89781NBC-2222-89781
ABC-2222-89782DEF-2222-89782GHT-2222-89782NBC-2222-89782ABC-2222-89782DEF-2222-89782GHT-2222-89782NBC-2222-89782
ABC-2223-89777DEF-2223-89780GHT-2223-89778NBC-1222-89781ABC-2222-89783DEF-2222-89783GHT-2222-89783NBC-2222-89783
ABC-2223-89778DEF-2223-89781GHT-2223-89779NBC-1222-89782ABC-2222-89784DEF-2222-89784GHT-2222-89784NBC-2222-89784
ABC-2223-89779GHT-2223-89780ABC-2222-89785DEF-2222-89785GHT-2222-89785NBC-2222-89785
ABC-2223-89780ABC-2222-89786DEF-2222-89786GHT-2222-89786NBC-2222-89786
ABC-2223-89781ABC-2222-89787DEF-2222-89787GHT-2222-89787NBC-2222-89787
ABC-2223-89782ABC-2222-89788DEF-2222-89788GHT-2222-89788NBC-2222-89788
ABC-2223-89783ABC-2222-89789DEF-2222-89789GHT-2222-89789NBC-2222-89789
ABC-2222-89790DEF-2222-89790GHT-2222-89790NBC-2222-89790
ABC-2222-89791DEF-2222-89791GHT-2222-89791NBC-2222-89791
ABC-2222-89792DEF-2222-89792GHT-2222-89792NBC-2222-89792
ABC-2222-89793DEF-2222-89793GHT-2222-89793NBC-2222-89793
ABC-2222-89794DEF-2222-89794GHT-2222-89794NBC-2222-89794
ABC-2222-89795DEF-2222-89795GHT-2222-89795NBC-2222-89795
ABC-2222-89796DEF-2222-89796GHT-2222-89796NBC-2222-89796
ABC-2222-89797DEF-2222-89797GHT-2222-89797NBC-2222-89797
ABC-2222-89798DEF-2222-89798GHT-2222-89798NBC-2222-89798
ABC-2222-89799DEF-2222-89799GHT-2222-89799NBC-2222-89799
ABC-2222-89800DEF-2222-89800GHT-2222-89800NBC-2222-89800
ABC-2222-89801DEF-2222-89801GHT-2222-89801NBC-2222-89801
ABC-2222-89802DEF-2222-89802GHT-2222-89802NBC-2222-89802
ABC-2222-89803DEF-2222-89803GHT-2222-89803NBC-2222-89803
ABC-2222-89804DEF-2222-89804GHT-2222-89804NBC-2222-89804
ABC-2222-89805DEF-2222-89805GHT-2222-89805NBC-2222-89805
ABC-2222-89806DEF-2222-89806GHT-2222-89806NBC-2222-89806
ABC-2222-89807DEF-2222-89807GHT-2222-89807NBC-2222-89807
ABC-2222-89808DEF-2222-89808GHT-2222-89808NBC-2222-89808
ABC-2222-89809DEF-2222-89809GHT-2222-89809NBC-2222-89809
ABC-2222-89810DEF-2222-89810GHT-2222-89810NBC-2222-89810
ABC-2222-89811DEF-2222-89811GHT-2222-89811NBC-2222-89811
ABC-2222-89812DEF-2222-89812GHT-2222-89812NBC-2222-89812
ABC-2222-89813DEF-2222-89813GHT-2222-89813NBC-2222-89813
ABC-2222-89814DEF-2222-89814GHT-2222-89814NBC-2222-89814
ABC-2222-89815DEF-2222-89815GHT-2222-89815NBC-2222-89815
ABC-2222-89816DEF-2222-89816GHT-2222-89816NBC-2222-89816
ABC-2222-89817DEF-2222-89817GHT-2222-89817NBC-2222-89817
ABC-2222-89818DEF-2222-89818GHT-2222-89818NBC-2222-89818
ABC-2222-89819DEF-2222-89819GHT-2222-89819NBC-2222-89819
ABC-2222-89820DEF-2222-89820GHT-2222-89820NBC-2222-89820
ABC-2222-89821DEF-2222-89821GHT-2222-89821NBC-2222-89821
ABC-2222-89822DEF-2222-89822GHT-2222-89822NBC-2222-89822
ABC-2222-89823DEF-2222-89823GHT-2222-89823NBC-2222-89823
ABC-2222-89824DEF-2222-89824GHT-2222-89824NBC-2222-89824
ABC-2222-89825DEF-2222-89825GHT-2222-89825NBC-2222-89825
ABC-2222-89826DEF-2222-89826GHT-2222-89826NBC-2222-89826
ABC-2222-89827DEF-2222-89827GHT-2222-89827NBC-2222-89827
ABC-2222-89828DEF-2222-89828GHT-2222-89828NBC-2222-89828
ABC-2222-89829DEF-2222-89829GHT-2222-89829NBC-2222-89829
ABC-2222-89830DEF-2222-89830GHT-2222-89830NBC-2222-89830
ABC-2222-89831DEF-2222-89831GHT-2222-89831NBC-2222-89831
ABC-2222-89832DEF-2222-89832GHT-2222-89832NBC-2222-89832
ABC-2222-89833DEF-2222-89833GHT-2222-89833NBC-2222-89833
ABC-2222-89834DEF-2222-89834GHT-2222-89834NBC-2222-89834
ABC-2222-89835DEF-2222-89835GHT-2222-89835NBC-2222-89835
ABC-2222-89836DEF-2222-89836GHT-2222-89836NBC-2222-89836
ABC-2222-89837DEF-2222-89837GHT-2222-89837NBC-2222-89837
ABC-2222-89838DEF-2222-89838GHT-2222-89838NBC-2222-89838
ABC-2222-89839DEF-2222-89839GHT-2222-89839NBC-2222-89839
ABC-2222-89840DEF-2222-89840GHT-2222-89840NBC-2222-89840
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
The sample does not describe expected output, only a "typical layout" of input data.

Prepare much shorter sample table - may be only 5 or 10 rows.
And fill not only
Data 1Data 2Data 3Data 4Main 1Main 2Main 3Main 4
but also
Match 1Match 2Match 3Match 4Different 1Different 2Different 3Different 4

With such few data, you could easily prepare this by copying and pasting.
Remember to show different scenarios, including for instance duplicates, total match, partial match, matched in different columns, etc.
 
Upvote 0
The sample does not describe expected output, only a "typical layout" of input data.

Prepare much shorter sample table - may be only 5 or 10 rows.
And fill not only
Data 1Data 2Data 3Data 4Main 1Main 2Main 3Main 4
but also
Match 1Match 2Match 3Match 4Different 1Different 2Different 3Different 4

With such few data, you could easily prepare this by copying and pasting.
Remember to show different scenarios, including for instance duplicates, total match, partial match, matched in different columns, etc.
Please help as data below:
Data 1Data 2Data 3Data 4Main 1Main 2Main 3Main 4Match 1Match 2Match 3Match 4Different 1Different 2Different 3Different 4
ABC2222123345DEF2222123345GHT2222123345NBC2222123345ABC098789766DEF098789766GHT098789766NBC098789766
ABC1111123345DEF1111123345GHT1111123345NBC1111123345ABC1111123345DEF1111123345GHT1111123345NBC1111123345
ABC222289765DEF222289780GHT222289765NBC222289765ABC128589771DEF128589771GHT128589771NBC128589771
ABC098789766DEF222289781GHT222389779NBC098789766ABC2222123345DEF2222123345GHT2222123345NBC2222123345
ABC222289767DEF222289782GHT222389780NBC222289767ABC222289765DEF222289765GHT222289765NBC222289765
ABC222289768DEF222389780NBC222289768ABC222289767DEF222289767GHT222289767NBC222289767
ABC222389780DEF222389781NBC222289769ABC222289768DEF222289768GHT222289768NBC222289768
ABC222389781NBC222289770ABC222289769DEF222289769GHT222289769NBC222289769
ABC222389782NBC128589771ABC222289770DEF222289770GHT222289770NBC222289770
ABC222389783NBC222289772ABC222289772DEF222289772GHT222289772NBC222289772
 
Upvote 0
So there is mo Matching and no different values? You left output columns empty.

1724320122056.png
 
Upvote 0
Compare data 1 to whole datasets Main 1, Main 2, Main 3, Main 4 or just current row Main 1, Main 2, Main 3, Main 4?
How about duplicates?
 
Upvote 0
Compare data 1 to whole datasets Main 1, Main 2, Main 3, Main 4 or just current row Main 1, Main 2, Main 3, Main 4?
How about duplicates?
Compare to whole all mains. Hope data no duplicate so find only match result and different.
 
Upvote 0
So there is mo Matching and no different values? You left output columns empty.

View attachment 115780
This is result:
Data 1Data 2Data 3Data 4Main 1Main 2Main 3Main 4Match 1Match 2Match 3Match 4Different 1Different 2Different 3Different 4
ABC2222123345DEF2222123345GHT2222123345NBC2222123345ABC098789766DEF098789766GHT098789766NBC098789766ABC2222123345DEF2222123345GHT2222123345NBC2222123345ABC222389780DEF222289780GHT222389779
ABC1111123345DEF1111123345GHT1111123345NBC1111123345ABC1111123345DEF1111123345GHT1111123345NBC1111123345ABC1111123345DEF1111123345GHT1111123345NBC1111123345ABC222389781DEF222289781GHT222389780
ABC222289765DEF222289780GHT222289765NBC222289765ABC128589771DEF128589771GHT128589771NBC128589771ABC222289765GHT222289765NBC222289765ABC222389782DEF222289782
ABC098789766DEF222289781GHT222389779NBC098789766ABC2222123345DEF2222123345GHT2222123345NBC2222123345ABC098789766NBC098789766ABC222389783DEF222389780
ABC222289767DEF222289782GHT222389780NBC222289767ABC222289765DEF222289765GHT222289765NBC222289765ABC222289767NBC222289767DEF222389781
ABC222289768DEF222389780NBC222289768ABC222289767DEF222289767GHT222289767NBC222289767ABC222289768NBC222289768
ABC222389780DEF222389781NBC222289769ABC222289768DEF222289768GHT222289768NBC222289768NBC222289769
ABC222389781NBC222289770ABC222289769DEF222289769GHT222289769NBC222289769NBC222289770
ABC222389782NBC128589771ABC222289770DEF222289770GHT222289770NBC222289770NBC128589771
ABC222389783NBC222289772ABC222289772DEF222289772GHT222289772NBC222289772NBC222289772
 
Upvote 0
Need to matching base on data 1 to data 4 compare with Main1 to Main 4 and get result 1 to result 4 and different 1 to different 4 as sample below.
try
Code:
Sub test()
    Dim a, b, i&, ii&, n&, x
    With [a1].CurrentRegion.Offset(1)
        .Columns(9).Resize(, .Columns.Count - 8).ClearContents
        a = .Value
        ReDim b(1 To UBound(a, 1) * 8)
        For i = 1 To UBound(a, 1) - 1
            For ii = 5 To 8
                If a(i, ii) <> "" Then n = n + 1: b(n) = a(i, ii)
            Next
        Next
        For i = 1 To UBound(a, 1) - 1
            For ii = 1 To 4
                If a(i, ii) <> "" Then
                    x = Application.Match(a(i, ii), b, 0)
                    If IsNumeric(x) Then
                        a(UBound(a, 1), ii) = a(UBound(a, 1), ii) + 1
                        a(a(UBound(a, 1), ii), ii + 8) = a(i, ii)
                    Else
                        a(UBound(a, 1), ii + 4) = a(UBound(a, 1), ii + 4) + 1
                        a(a(UBound(a, 1), ii + 4), ii + 12) = a(i, ii)
                    End If
                End If
            Next
        Next
        .Resize(.Rows.Count - 1).Value = a
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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