Find/match values in 5 consecutive cells in one row with the same 5 values in a different range.

coveredinbutter

New Member
Joined
Dec 20, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Looking for some guidance

Not sure if I explained in correctly in the title:

For the values in cells A1, B1,C1,D1,E1, F1, G1. I want to find the row in range J1:P50 where every value in the row matches the values in A1:G1.

Any help is appreciated.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Maybe this?

Find-match values in 5 consecutive cells in one row_coveredinbutter.xlsx
ABCDEFGJKLMNOP
112345671030507090110130
21131517191111131
3Row1232527292112132
471333537393113133
51434547494114134
61535557595115135
71234567
81737577797117137
91838587898118138
101939597999119139
1120406080100120140
1221416181101121141
1322426282102122142
1423436383103123143
1524446484104124144
1625456585105125145
1726466686106126146
Sheet1
Cell Formulas
RangeFormula
K1:P6,K8:P17K1=J1+20
A4A4=SUMPRODUCT(($J$1:$J$50=$A$1)*($K$1:$K$50=$B$1)*($L$1:$L$50=$C$1)*($M$1:$M$50=$D$1)*($N$1:$N$50=$E$1)*($O$1:$O$50=$F$1)*($P$1:$P$50=$G$1)*(ROW($J$1:$J$50)-ROW($J$1)+1))
 
Upvote 0
Here is a vba macro code approach:

VBA Code:
Sub FindMatch()
'
    Dim ColumnCounter   As Long
    Dim FirstRowToLoad  As Long, MaxRowToLoad   As Long
    Dim ArrayAtoG       As Variant, ArrayJtoP   As Variant
'
    FirstRowToLoad = 1                                                              ' <--- Set this to first row to load
    MaxRowToLoad = 50                                                               ' <--- Set this to last row to load
'
    ArrayAtoG = Range("A1:G1")                                                      ' Load A1:G1 to 2D One based array ... RC ... 1,1 thru 1,7
'
    ArrayJtoP = Range("J" & FirstRowToLoad & ":P" & MaxRowToLoad)                   ' Load J:P range into 2D One based ArrayJtoP ... RC
'
    ColumnCounter = 1                                                               ' Initialize ColumnCounter
'
    For ArrayJtoP_Row = FirstRowToLoad To MaxRowToLoad                              ' Loop to loop through ArrayJtoP
        If ArrayJtoP(ArrayJtoP_Row, ColumnCounter) = ArrayAtoG(1, 1) And _
            ArrayJtoP(ArrayJtoP_Row, ColumnCounter + 1) = ArrayAtoG(1, 2) And _
            ArrayJtoP(ArrayJtoP_Row, ColumnCounter + 2) = ArrayAtoG(1, 3) And _
            ArrayJtoP(ArrayJtoP_Row, ColumnCounter + 3) = ArrayAtoG(1, 4) And _
            ArrayJtoP(ArrayJtoP_Row, ColumnCounter + 4) = ArrayAtoG(1, 5) And _
            ArrayJtoP(ArrayJtoP_Row, ColumnCounter + 5) = ArrayAtoG(1, 6) And _
            ArrayJtoP(ArrayJtoP_Row, ColumnCounter + 6) = ArrayAtoG(1, 7) Then      '   If all values match then ...
                MsgBox "Match found in row " & ArrayJtoP_Row                        '       Display Message box indicating the matching row
                Exit Sub                                                            '       Exit this sub
        End If
    Next                                                                            ' Loop back
End Sub
 
Upvote 0
Welcome to the MrExcel board!

Do the numbers have to be in the exact same order?
For example, would it still be row 7 with this sample data?

21 12 21.xlsm
ABCDEFGHIJKLMNOP
112345671030507090110130
21131517191111131
3Row1232527292112132
41333537393113133
51434547494114134
61535557595115135
76174325
81737577797117137
Sheet2 (2)
 
Upvote 0
Thanks everyone. I was trying to do a lookup with the 7 values to another 7 values and I think I was making it too complicated. I was able to make it work with an xlookup using this format.

=XLOOKUP(val1&val2&val3,rng1&rng2&rng3,results)

Thanks for all the help.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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