Matching multiple criteria across multiple columns and rows

okadike

New Member
Joined
Jul 1, 2018
Messages
3
Can somebody help? My data set is as displayed below: same sheet and same rows but different columns. Data on the left is 20 rows by 10 columns; data on the right 20 rows by 5 columns. Data distribution is arbitrary in both. The task is to get a function to match a row that has at least 3 numbers in common and 3 criteria as in red.

Eg 59,70 and 13 are 3 criteria and 71,8,55 are common between the two data sets on row 6 number 6. The numbers are all random selection. Nothing fixed.

90455924482388519684425121831
342025881110476513173066623256
84561843751288975863587396742
429089198763141245332079723528
2269126519158238184865375417
598355457175701355587177855
62823923492465369857873101722
514145267415822965733587677988
26744765325950418251267885651
121929554171472854248014836910
3747432465624341553815128831
782527613177651704727274376
7580106350915855414539734364
70332276836845348275123874569
4987833941686615765577333437
326685613641795787029112865
84905144471341782342541255
Criteria example597013

<tbody>
</tbody>
<strike></strike>
<strike></strike>

<tbody>
</tbody>
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
okadike,

You might consider the following...

Code:
Function RowNumber(cr1 As Long, cr2 As Long, cr3 As Long)
Dim arr As Variant
Dim r As Long, c1 As Long, c2 As Long
Dim kounter As Long, kounterCr

arr = ActiveSheet.Range("A1:S" & Cells(Rows.Count, "A").End(xlUp).Row).Value
For r = 1 To UBound(arr)
    kounter = 0
    kounterCr = 0
    For c1 = 1 To 10
        If arr(r, c1) = cr1 Or arr(r, c1) = cr2 Or arr(r, c1) = cr3 Then
            kounterCr = kounterCr + 1
        End If
        For c2 = 15 To 19
            If arr(r, c1) = arr(r, c2) Then
                kounter = kounter + 1
            End If
        Next c2
    Next c1
    If kounter > 2 And kounterCr > 2 Then
        RowNumber = r
    End If
Next r
End Function

Cheers,

tonyyy
 
Upvote 0
Tonyyy,
Thanks a lot. I am not familiar with coding. Looking at the data I submitted as columns C to L and Q to U, I was looking at a formula I can use. I managed to put together
=IF(IFERROR(INDEX(C1:C20,MATCH(1,((C21=C1:C20)+(C21=D1:D20)+(C21=E1:E20)+(C21=F1:F20)+(C21=G1:G20)+(C21=H1:H20)+(C21=I1:I20)+(C21=J1:J20)+(C21=K1:K20)+(C21=L1:L20))*((D21=C1:C20)+(D21=D1:D20)+(D21=E1:E20)+(D21=F1:F20)+(D21=G1:G20)+(D21=H1:H20)+(D21=I1:I20)+(D21=J1:J20)+(D21=K1:K20)+(D21=L1:L20))*((E21=C1:C20)+(E21=D1:D20)+(E21=E1:E20)+(E21=F1:F20)+(E21=G1:G20)+(E21=H1:H20)+(E21=I1:I20)+(E21=J1:J20)+(E21=K1:K20)+(E21=L1:L20)),0)),0)>0,"YES",0)

I was only able to get one part …. but even at that the formula is too cumbersome. I need something simpler and better..
Thanks again


<colgroup><col></colgroup><tbody>
</tbody>
<strike></strike><strike></strike>
 
Upvote 0
One way using a helper column...

With
- criteria in cells A1,B1,C1
- left data range A2:J18
- right data range O2:S18

Put this formula in U2 and copy down
Code:
=(COUNTIF(A2:J2,O2)+COUNTIF(A2:J2,P2)+COUNTIF(A2:J2,Q2)+COUNTIF(A2:J2,R2)+COUNTIF(A2:J2,S2)>2)*(COUNTIF(A2:J2,$A$1)+COUNTIF(A2:J2,$B$1)+COUNTIF(A2:J2,$C$1)=3)

And this formula in D1
Code:
=MATCH(1,U:U,0)

D1 returns 7 which is the correct row


Assumes both sets of values within each row are unique - duplicate values have not been considered
 
Last edited:
Upvote 0
Yongle,
Thanks a lot for your response. However it does not address my situation. Consider it that the 20 x 10 and 10 x 5 data set is a packet. That means, I need a formula to address A2:J21 with O2:S21 together in one cell. Your idea is good for A2:J2 with O2:S2 but not all the data set together. See my effort below at putting everything together...

=IF(IFERROR(INDEX(C1:C20,MATCH(1,((C21=C1:C20)+(C21=D1:D20)+(C21=E1:E20)+(C21=F1:F20)+(C21=G1:G20)+(C21=H1:H20)+(C21=I1: I20)+(C21=J1:J20)+(C21=K1:K20)+(C21=L1:L20))*((D21=C1:C20)+(D21=D1:D20)+(D21=E1:E20)+(D21=F1:F20)+(D21=G1:G20)+(D21=H1:H 20)+(D21=I1:I20)+(D21=J1:J20)+(D21=K1:K20)+(D21=L1:L20))*((E21=C1:C20)+(E21=D1:D20)+(E21=E1:E20)+(E21=F1:F20)+(E21=G1:G2 0)+(E21=H1:H20)+(E21=I1:I20)+(E21=J1:J20)+(E21=K1:K20)+(E21=L1:L20)),0)),0)>0,"YES",0)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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