VLOOKUP with multiple outcomes, problem

alanbarry

New Member
Joined
Jul 12, 2013
Messages
9
I hope you can help me with a Excel VLOOKUP problem that I have. Having read through these fora, I realise that there are many knowledgeable people here!

My problem is this;

I have a workbook with multiple sheets. On Sheet 1, I have an X & Y axis style table set up, with a set of identifier codes in the X axis, and a set of classification codes in the Y axis.

On Sheet 2, I have a simple 2 column table, which lists the identifier codes in Column 1, matched with the classification codes in Column 2.

I want the text “TRUE” to appear on Sheet 1, every time the identifier code (X axis) matches a classification code (Y axis), pulling the data from Sheet 2 (i.e. to fill in the table with TRUE if there is a match, or leave blank if not).

The problem being, many of the identifier codes are associated with multiple classification codes on Sheet 2.

I have written the formula;

• =IF((VLOOKUP(H5,’Sheet 2'!$B$5:$C$1713,2,FALSE)=$I$4),"TRUE","")


Where H5 in the Identifier Code on Sheet 1, B5:C1713 are the classification codes array on Sheet 2 and I4 is the Classification code on Sheet 1. So if the VLOOKUP pulls the classification code from Sheet 2, and it matches the Classification code on Sheet 1, I get the text "TRUE".


This formula is working to an extent, in that it returns the “TRUE” value for the first instance of the identifier code matching a classification code (the VLOOKUP Function). However, for subsequent matches, this formula is not returning the subsequent matched data. That is, I want TRUE to appear three times (in this instance), once for each VLOOKUP match, but it only appears for the first one.

So for example; the first identifier code 2xxxxx2252 is associated with the classification codes 180000015, 180000117 and 180000155 on ‘Sheet 2’. What I want here is for TRUE to appear on ‘Sheet 1’ every time any of these codes is listed, i.e. I should have TRUE three times across Row X on the sheet. It, however, only appears once for the 2xxxxx2252/180000015 association. It is putting 18000015 into each match,not 18000015 AND 180000117 AND 180000155.

I understand that VLOOKUP is a vertical only formula, so I have not used the fill handle to copy across; I have rewritten the formula for each column, referencing the correct cells.

If there is any to make a VLOOKUP formula return multiple outcomes, I would really appreciate advice to send me in the correct direction. I am very much so a beginner at Excel! I hope this makes sense.

Thank you,
Alan.
 
your definition of your problem is way to complicated to understand - make a very simple example up with only 4 or 5 rows and explain what you want to do
example

sheet 1
ab 5 true
ab 7 true
ab 13 true

sheet 2


ab 5
ab 9
ab 22
 
Upvote 0
your definition of your problem is way to complicated to understand - make a very simple example up with only 4 or 5 rows and explain what you want to do
example

sheet 1
ab 5 true
ab 7 true
ab 13 true

sheet 2


ab 5
ab 9
ab 22

My apologies!

For example.



Sheet 1
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]180010[/TD]
[TD]180011[/TD]
[TD]180012[/TD]
[TD]180013[/TD]
[TD]180014[/TD]
[TD]180015[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1235[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1236[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Sheet 2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]ID Code[/TD]
[TD]Classification Code[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]180010[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]180012[/TD]
[/TR]
[TR]
[TD]1235[/TD]
[TD]180014[/TD]
[/TR]
[TR]
[TD]1236[/TD]
[TD]180010[/TD]
[/TR]
</tbody>[/TABLE]
What I need is to have TRUE listed in Sheet 1 wherever there is a match on Sheet 2; i.e. there should be TRUE under 180010 and 180012 in the row(s) for ID Code 1234. But all remaining fields in the row would be blank.

My ideal outcome would be
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]180010[/TD]
[TD]180011[/TD]
[TD]180012[/TD]
[TD]180013[/TD]
[TD]180014[/TD]
[TD]180015[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1235[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]TRUE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1236[/TD]
[TD]TRUE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Hopefully this helps, many thanks for replying.
 
Upvote 0
I'm with oldbrewer, too much to digest.

Vlookup can return multiple values from the lookup_array but is pretty much worthless if you are trying to look up the value of H5 in column B and the H5 value is listed multiple times in column B. Returning the first occurrence is what it does in this case.

Code:
• =IF((VLOOKUP(H5,’Sheet 2'!$B$5:$C$1713,2,FALSE)=$I$4),"TRUE","")

Regards,
Howard
 
Upvote 0
Ok, thanks Howard. As I said, I have quite a basic knowledge of Excel, so I am not too sure which function could help me solve my issue (I am sure there is one somewhere though!).

I have since posted an example above, hopefully this may be easier to understand. I agree with both of you with regards to the level of information I provided originally.. Too much!! I was typing without thinking!!

Thanks!
 
Upvote 0
try this
Excel Workbook
AB
1ID CodeClassification Code
21234180010
31234180012
41235180014
51236180010
Sheet6
Excel 2010
Excel Workbook
ABCDEFG
1180010180011180012180013180014180015
21234TRUETRUE
31234TRUETRUE
41234TRUETRUE
51235TRUE
61236TRUE
Sheet5
Excel 2010
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
 
Upvote 0
or a non-array formula solution
Excel Workbook
ABCDEFG
1180010180011180012180013180014180015
21234TRUETRUE
31234TRUETRUE
41234TRUETRUE
51235TRUE
61236TRUE
Sheet5
Excel 2010
Cell Formulas
RangeFormula
B2=IF(COUNTIFS(Sheet6!$A$1:$A$5,$A2,Sheet6!$B$1:$B$5,B$1),TRUE,"")
 
Upvote 0
THANK YOU SO MUCH!!

I used the first post reply with the Array formula, and it worked perfectly. I literally cannot thank you enough.

Thanks!
Alan.
 
Upvote 0

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