VLookup or Offset Match for multiple criteria

geigMR

Board Regular
Joined
Sep 27, 2011
Messages
51
Hi folks

I'm not quite sure how or if this is possible but what I am wanting to do is lookup a number of column fields in another worksheet and if they ALL match exactly then return a value from that sheet. Any help would be massively appreciated! I have 3 sheets and at the far right of the 3rd sheet ('hun') I have 2 results columns: one to lookup to worksheet 1 ('arq') and the other to lookup to worksheet 2 ('jot').

Please see my attached spreadsheet. I have manually entered the results in columns U & V of 'hun' that should happen if the formula/macro works correctly. The columns in 'hun' that should be matched exactly in the other sheets are titled 'cgt', 'app', 'pinto', 'fen', 'iso', 'con', & 'res'.

sheet1:
Excel 2012
ABCDEFGHIJKLMNOPQ
1DATED:11/12/2015
2proBcgtapppintofenisoconresJKLMNOarqFIGQ
3HK72115/(-281R)misc0.40GBBD2BGRXRXNmiscmiscmiscmiscmiscmisc612misc
4HK72685/(-152R)misc0.40GBD2BGRXBGNmiscmiscmiscmiscmiscmisc606misc
5HK79895/(-239R)misc0.40FBD2BGRXBGNmiscmiscmiscmiscmiscmisc552misc
6HK85111/-239Rmisc0.41GBD2RxRXRXNmiscmiscmiscmiscmiscmisc493misc
7HK85332/(-239R)misc0.43FBBD2BGBGBGNmiscmiscmiscmiscmiscmisc572misc
8HK90113/(-239R)misc0.45GDI1GRXBGNmiscmiscmiscmiscmiscmisc434misc
9HK90115/(-219R)misc0.45FDI1IDIDIDNmiscmiscmiscmiscmiscmisc434misc
10HK90116/(-269R)misc0.46GDI1BGBGBGNmiscmiscmiscmiscmiscmisc434misc
11HK90202/(-298R)misc0.47GBBD1RXRXBGNmiscmiscmiscmiscmiscmisc440misc
12HK90204/(-219R)misc0.49GDI1BGRXRXNmiscmiscmiscmiscmiscmisc434misc

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
arq



Sheet2:
Excel 2012
ABCDEFGHIJKLMNOPQR
1DATED:11/12/2015
2AprocgtDapppintoGfenisoconresLMNOPjotFIGR
3miscLKEK/72598/G0.40miscFBD2miscRXBGRXGNTmiscmiscmiscmiscmisc£510.00misc
4miscLKEK/84116/G0.40miscGBD2miscBGRXBGGNTmiscmiscmiscmiscmisc£490.00misc
5miscLKEK/89820/G0.42miscGBD2miscRXRXRXNmiscmiscmiscmiscmisc£512.00misc
6miscLKEK/02948/G0.42miscGBD2miscRXRXRXNmiscmiscmiscmiscmisc£512.00misc
7miscLKEK/98081/G0.42miscFDI1miscRXBGBGNmiscmiscmiscmiscmisc£452.00misc
8miscLKEK/52737/G0.44miscFDI1miscRXBGBGNmiscmiscmiscmiscmisc£452.00misc
9miscLKEK/16442/G0.45miscFDI1miscIDIDIDNmiscmiscmiscmiscmisc£442.80misc
10miscLKEK/44604/G0.45miscFDI1miscBGIDIDNmiscmiscmiscmiscmisc£524.80misc
11miscLKEK/88690/G0.45miscFDI1miscRXRXRXNmiscmiscmiscmiscmisc£463.30misc
12miscLKEK/89409/G0.48miscGDI1miscRXRXRXNmiscmiscmiscmiscmisc£466.20misc

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
jot



Sheet3:
Excel 2012
ABCDEFGHIJKLMNOPQRSTUV
1DATED:08/12/2015rate0.657255
2proBcgtDapppintofenisoconJKLresNOPQRShunFIGarqFIGjotFIG
3VE4D62A2-19misc0.40miscFDI1BGRXBGmiscmiscmiscNmiscmiscmiscmisc$754 misc£496not foundnot found
4VE22B85Z13-198misc0.40miscFBD2BGRXBGmiscmiscmiscNmiscmiscmiscmisc$853 misc£561£552not found
5VE14B70H18-662misc0.43miscFBBD1GRXBGmiscmiscmiscFmiscmiscmiscmisc$794 misc£522not foundnot found
6VE22B22Z20-44misc0.43miscFBBD2IDRXIDmiscmiscmiscNmiscmiscmiscmisc$928 misc£610not foundnot found
7VE1A07E1-539misc0.44miscFBD1IDIDIDmiscmiscmiscNmiscmiscmiscmisc$918 misc£604not foundnot found
8VE8Z33E15-5misc0.45miscFDI1BGIDIDmiscmiscmiscNmiscmiscmiscmisc$764 misc£502not found£524.80
9VE8C53F15-431misc0.45miscFDI1IDIDIDmiscmiscmiscNmiscmiscmiscmisc$782 misc£514£434£442.80
10VE6H81B15-341misc0.47miscGBD2GBGBGmiscmiscmiscMmiscmiscmiscmisc$640 misc£421not foundnot found
11VE10Z04G11-232Amisc0.47miscGBBD1RXRXBGmiscmiscmiscNmiscmiscmiscmisc$916 misc£602£440not found
12VE14B70H18-1201misc0.49miscGDI1RXIDIDmiscmiscmiscNmiscmiscmiscmisc$748 misc£492not foundnot found

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
hun




I have noticed that the 'jotFIG' figures (that are pasted from an external source) in col. Q of sheet 2 have four spaces to right so do not in fact have a number format, so I don't know if it is possible to also incorporate some kind of trim function that changes this to a number.

Thanks for any help!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
It would be easier to understand if you made up 3 tiny tables with only 3 or 4 columns and rows and asked the question in terms of those.

I cannot understand what you are trying to do at present
 
Upvote 0
Thanks for your reply.

I have removed extraneous columns (see below). Basically, the ‘results’ columns of the formula/macro are cols J & K on sheet3 (‘hun’).

Col J looks up the matching data on sheet1 (‘arq’) and if matched returns sheet1’s col.I.

Col K looks up the matching data on sheet2 (‘jot’) and if matched returns sheet2’s col.I.

The columns to be matched (exactly) are cols B-H on the respective sheets.

(As mentioned, it appears the col.I figs on sheet2 have four spaces to right so do not have a number format, so I was hoping it woud be possible to also incorporate some kind of trim function that changes this to a number).

I hope I have explained this ok – please let me know.

sheet3:

Excel 2012
ABCDEFGHIJK
1procgtapppintofenisoconreshunFIGarqFIGjotFIG
2VE4D62A2-190.40FDI1BGRXBGN£496not foundnot found
3VE22B85Z13-1980.40FBD2BGRXBGN£561£552not found
4VE14B70H18-6620.43FBBD1GRXBGF£522not foundnot found
5VE22B22Z20-440.43FBBD2IDRXIDN£610not foundnot found
6VE1A07E1-5390.44FBD1IDIDIDN£604not foundnot found
7VE8Z33E15-50.45FDI1BGIDIDN£502not found£524.80
8VE8C53F15-4310.45FDI1IDIDIDN£514£434£442.80
9VE6H81B15-3410.47GBD2GBGBGM£421not foundnot found
10VE10Z04G11-232A0.47GBBD1RXRXBGN£602£440not found
11VE14B70H18-12010.49GDI1RXIDIDN£492not foundnot found
hun


Sheet1:

Excel 2012
ABCDEFGHI
1procgtapppintofenisoconresarqFIG
2HK72115/(-281R)0.40GBBD2BGRXRXN612
3HK72685/(-152R)0.40GBD2BGRXBGN606
4HK79895/(-239R)0.40FBD2BGRXBGN552
5HK85111/-239R0.41GBD2RxRXRXN493
6HK85332/(-239R)0.43FBBD2BGBGBGN572
7HK90113/(-239R)0.45GDI1GRXBGN434
8HK90115/(-219R)0.45FDI1IDIDIDN434
9HK90116/(-269R)0.46GDI1BGBGBGN434
10HK90202/(-298R)0.47GBBD1RXRXBGN440
11HK90204/(-219R)0.49GDI1BGRXRXN434
arq


Sheet2:

Excel 2012
ABCDEFGHI
1procgtapppintofenisoconresjotFIG
2LKEK/72598/G0.40FBD2RXBGRXGNT£510.00
3LKEK/84116/G0.40GBD2BGRXBGGNT£490.00
4LKEK/89820/G0.42GBD2RXRXRXN£512.00
5LKEK/02948/G0.42GBD2RXRXRXN£512.00
6LKEK/98081/G0.42FDI1RXBGBGN£452.00
7LKEK/52737/G0.44FDI1RXBGBGN£452.00
8LKEK/16442/G0.45FDI1IDIDIDN£442.80
9LKEK/44604/G0.45FDI1BGIDIDN£524.80
10LKEK/88690/G0.45FDI1RXRXRXN£463.30
11LKEK/89409/G0.48GDI1RXRXRXN£466.20
jot


Thanks
 
Upvote 0
Col J looks up the matching data on sheet1 (‘arq’) and if matched returns sheet1’s col.I.

what does looks up the matching data mean ( I know how vlookup works)
 
Upvote 0
sorry, I mean I'd like the formula/macro to compare cols B-H on both sheets, and if they match exactly then I'd like the value in col.I of sheet1 to be returned in sheet3. I have manually entered these results in col. J of sheet3 to show what the results should be.
 
Upvote 0
procgtapppintofenisoconresarqFIG
HK72115/(-281R)0.4GBBD2BGRXRXN612for each row in first table
HK72685/(-152R)0.4GBD2BGRXBGN606check if there is a row
HK79895/(-239R)0.4FBD2BGRXBGN552with columns B to H
HK85111/-239R0.41GBD2RxRXRXN493exactly the same
HK85332/(-239R)0.43FBBD2BGBGBGN572
HK90113/(-239R)0.45GDI1GRXBGN434
HK90115/(-219R)0.45FDI1IDIDIDN434
HK90116/(-269R)0.46GDI1BGBGBGN434I changed the first rows to match for testing purposes
HK90202/(-298R)0.47GBBD1RXRXBGN440
HK90204/(-219R)0.49GDI1BGRXRXN434the macro found the only 2 matching rows
not sure what you want in col A and col I
of the output table
MACRO
rownum = 39
procgtapppintofenisoconresjotFIG For a = 5 To 14
LKEK/72598/G0.4GBBD2BGRXRXN£510.00 For b = 2 To 8
LKEK/84116/G0.4GBD2BGRXBGGNT£490.00 c = a + 20
LKEK/89820/G0.42GBD2RXRXRXN£512.00 If Cells(a, b) = Cells(c, b) Then sum = sum + 1
LKEK/02948/G0.42GBD2RXRXRXN£512.00 Next b
LKEK/98081/G0.42FDI1RXBGBGN£452.00 If sum = 7 Then GoTo 200 Else GoTo 300
LKEK/52737/G0.44FDI1RXBGBGN£452.00200 sum = 0
LKEK/16442/G0.45FDI1IDIDIDN£442.80 rownum = rownum + 1
LKEK/44604/G0.45FDI1BGIDIDN£524.80 For z = 2 To 8
LKEK/88690/G0.45FDI1RXRXRXN£463.30 Cells(rownum, z) = Cells(a, z)
LKEK/89409/G0.48GDI1RXRXRXN£466.20 Next z
300 sum = 0
Next a
End Sub
0.4GBBD2BGRXRXN
0.45FDI1IDIDIDN

<colgroup><col><col span="15"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi
Unfortunately that does not seem to work for me. The only data I want to pull is the price from column I in sheet1 and sheet2. The only columns I want to be populated are column J and column K in sheet1 ('hun'), with the prices from sheet1 and sheet2 respectively - and only IF their respective columns B-H match with sheet1's. Column A on each sheet is irrelevant.

Thanks v much for any help with this!
 
Upvote 0
please note that in my example I have filled in the dummy results - in column J & K - as they should appear from the macro. In my actual spreadsheet these two columns will be empty, until the macro is run.
 
Upvote 0
so you just need to add a few lines to my macro to print out both prices - change for z = 2 to 8 to for z=2 to 9
then you need to add, - straight after next z, cells(rownum,z+1)=cells(c,9)

you might need to have a zz=z in the loop and use cells(rownum(zz)
 
Upvote 0
Unfortunately this is not working for me. I run the macro and nothing happens. I'm afraid I do not know much about VBA but this is the macro if I've understood your instructions correctly:
Sub test()
'
' test Macro
'


'
rownum = 39
For a = 5 To 14
For b = 2 To 8
c = a + 20
If Cells(a, b) = Cells(c, b) Then Sum = Sum + 1
Next b
If Sum = 7 Then GoTo 200 Else GoTo 300
200 Sum = 0
rownum = rownum + 1
For Z = 2 To 9
Cells(rownum, Z) = Cells(a, Z)
Next Z
Cells(rownum, Z + 1) = Cells(c, 9)
300 Sum = 0
Next a




End Sub

Not sure how/where to insert
a zz=z in the loop and use cells(rownum(zz)


Thanks for any answers to this.
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,945
Members
449,275
Latest member
jacob_mcbride

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