Find 3 matches within 5 columns highlight and get summary

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

I got data base in the 5 columns in the D:H cells D6:H59 (my actually data base is in the range D6:H4108) I want to get highlighted 3 match within 5 columns in the any position and (optional is possible to get match count summary in the cells J6: N to down in the columns.

Count 3 Match
n1n2n3n4n5n1n2n3n4n5Total Find
41224273614102
14101923110484
141528354016134
122021454849212
110121648446482
3812294359212
12373940502738482
10284047481047482
372545501415352
691525381846482
59192138
57142049
28173250
1415253547
59202126
1020222431
49152147
527314042
16133049
1324264749
1823374648
1114242529
37122634
110173348
56113044
815263048
1022273848
717203550
110444548
1025414748
68273741
1213172243
519314350
16132228
2021273340
39203042
1015174045
1013203341
16131726
110293848
58142232
14104145
712273848
1525264041
1828394648
923294149
16131516
525323743
318222732
49142127
48111946
412254648
219242649
45394648

For example the sample image is attached.

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • Find 3 matches.png
    Find 3 matches.png
    60.1 KB · Views: 14

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Here is one idea to consider. What makes this more difficult is that for every set of five numbers, there are 10 possible combinations that need to be considered. By using helper columns, you could explicitly list these combinations (see the table with blue heading) and then search the entire table of combinations for duplicates. The example here uses this approach, and to clarify which group of three will be taken from the five numbers, you will see an array of the form {1,1,1,0,0}, which means use the 1st, 2nd, and 3rd numbers and omit the 4th and 5th. These arrays change for each of the 10 columns and are (unfortunately) embedded in the formulas in three places. Since you are using Excel 2000, the use of the TEXTJOIN function, which I used here, is probably not an option, but you can accomplish exactly the same text strings using a construction like this:
Excel Formula:
=CONCATENATE(INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,1,0,0},1)),
        ,",",INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,1,0,0},2)),
        ,",",INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,1,0,0},3))
)
...which should work fine in Excel 2000.

This approach assumes that the original sets of five numbers are in sorted order, from least to greatest. For the sake of brevity, I've only shown five rows of numbers, and I've changed some of the original values so that some duplicates would be found. The duplicate counts are shown in the "Matches" table (green heading).

A VBA solution is probably preferred here, as the number of combinations and the fact that potential matches are spread across 10 columns complicates being able to extract a unique list of duplicates across those 10 columns. Perhaps someone has a clever way to do that. For now, I've used Conditional Formatting to search the table and highlight duplicates. In the example shown, some of the matches indicated by highlighting and counts>1 may not be obvious because the entire table is not shown.
Cell Formulas
RangeFormula
J7:J11J7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,1,0,0},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,1,0,0},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,1,0,0},3)) )
K7:K11K7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,0,1,0},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,0,1,0},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,0,1,0},3)) )
L7:L11L7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,0,0,1},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,0,0,1},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,1,0,0,1},3)) )
M7:M11M7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,1,1,0},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,1,1,0},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,1,1,0},3)) )
N7:N11N7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,1,0,1},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,1,0,1},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,1,0,1},3)) )
O7:O11O7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,0,1,1},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,0,1,1},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{1,0,0,1,1},3)) )
P7:P11P7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,1,1,0},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,1,1,0},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,1,1,0},3)) )
Q7:Q11Q7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,1,0,1},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,1,0,1},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,1,0,1},3)) )
R7:R11R7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,0,1,1},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,0,1,1},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,1,0,1,1},3)) )
S7:S11S7=TEXTJOIN(",",1, INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,0,1,1,1},1)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,0,1,1,1},2)), INDEX($D7:$H7,AGGREGATE(15,6,(COLUMN($D$6:$H$6)-COLUMN($C$6))/{0,0,1,1,1},3)) )
U7:AD11U7=IF(COUNTIF($J$7:$S$61,J7)>1,COUNTIF($J$7:$S$61,J7),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J7:S61Cell ValueduplicatestextNO
 
Upvote 0
Here is one idea to consider. What makes this more difficult is that for every set of five numbers, there are 10 possible combinations that need to be considered.

Hello KRice, I can imagine you have spend a lot of time in it really I am very grateful to you for taking a time and trying to solve my query I understood completely you viewpoint breaking firstly in 10 unique possible combinations and then find out 3 matches it is really clever and interesting thought.

Applying both the formula "=CONCATENATE" or "=TEXTJOIN" Gives an error #NAME? Only the formula works correct is for U7 regarding the error #NAME? I goggled but could not find any way to get it worked either there is syntax or it is not applied for my older version not sure. Please can you take a look?

Have a good week ahead

Kind Regards,
Moti
 
Upvote 0
@KRice
The aggregate function only came out in 2010, so won't work for the OP.
 
Upvote 0
Thanks, Fluff. I didn't realize that. I thought AGGREGATE had been around longer.
 
Upvote 0
Unfortunately not, although it does seem as if it's been around forever.
 
Upvote 0
How about this approach, where the first three rows are helper rows to describe the index of the array formed from the original 5 numbers. I think this uses functions that should be available in Excel 2000.
Cell Formulas
RangeFormula
J6:S10J6=CONCATENATE(INDEX($D6:$H6,J$1),",",INDEX($D6:$H6,J$2),",",INDEX($D6:$H6,J$3))
U6:AD10U6=SUMPRODUCT(--($J$6:$S$10=J6))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
U6:AD10Cell Value>1textNO
J6:S10Cell ValueduplicatestextNO
 
Upvote 0
Solution
Maybe something like...

Pasta1
DEFGHIJKLMNO
5n1n2n3n4n5n1n2n3n4n5Total Find
641224273614102
714101923110484
8141528354016134
9122021454849212
10110121648446482
113812294359212
1212373940502738482
1310284047481047482
14372545501415352
15691525381846482
1659192138
1757142049
1828173250
191415253547
2059202126
211020222431
2249152147
23527314042
2416133049
251324264749
261823374648
271114242529
2837122634
29110173348
3056113044
31815263048
321022273848
33717203550
34110444548
351025414748
3668273741
371213172243
38519314350
3916132228
402021273340
4139203042
421015174045
431013203341
4416131726
45110293848
4658142232
4714104145
48712273848
491525264041
501828394648
51923294149
5216131516
53525323743
54318222732
5549142127
5648111946
57412254648
58219242649
5945394648
Plan2
Cell Formulas
RangeFormula
O6:O15O6=SUMPRODUCT(--(MMULT(--(ISNUMBER(MATCH($D$6:$H$59,$J6:$N6,0))),{1;1;1;1;1})=3))


Hope this helps

M.
 
Upvote 0
To highlight you would need 10 different rules in Conditional Formatting, one for each row in J:N, but as far as i know Excel 2000 does not accept so many rules in CF.

Maybe someone else could help with a macro to do it.

M.
 
Upvote 0
Maybe something like...
Hope this helps

M.
Hello Marcelo Branco, Thank you for the formula I wanted to find also the matched pattern in the example I just put them manually but I will put the formula in my folder to use it any time I required.

To highlight you would need 10 different rules in Conditional Formatting, one for each row in J:N, but as far as i know Excel 2000 does not accept so many rules in CF.

Maybe someone else could help with a macro to do it.

M.
Regarding the CF I do applied formula "=IF(U6>1,1,0)" with the KRice, results which worked ok.

Good Luck

Kind Regards,
Moti
 
Upvote 0

Forum statistics

Threads
1,214,999
Messages
6,122,645
Members
449,093
Latest member
Ahmad123098

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