HELP on INDEX/MATCH multiple ocurence match values needed ..DRIVING ME CRAZY!!!

buddy1000

Active Member
Joined
Oct 31, 2007
Messages
294
example.xls
ABCD
1CcodeIcodenr.
21000200AA12545811000
31000200DE12545616980
41000200BB54879022960
51000200MM5487528940
61000200PP12487834920
71000200AA12545840900
81000200BB54879046880
91000200KL24554252860
101000200DE12545646880
111000120AA12545852860
121000120TY78425958840
131000120BB54879064820
141000120MQ54878770800
15
16
INPUT 1
example.xls
ABCD
1CcodeIcodenr.
2SABBAA12545811000
3SABBDE12545616980
4SABBBB54879022960
5SABBMM5487528940
6SABBPP12487834920
7SABB-2AA12545840900
8SABBBB54879046880
9SABBKL24554252860
10SABB-2DE12545646880
11BASSAA12545852860
12BASSTY78425958840
13BASSBB54879064820
14BASSMQ54878770800
INPUT 2


I am trying to lookup values with multiple occurence by using Index/match.

I have 3 sheets
Input sheet 1, Input sheet 2 and a Sheet I call Lookup.
In input sheet 1, I have a column Ccode, Icode and nr.
In input sheet 2 ,I have the same columns.
Icode and nr. sheets are SIMILAIR in both sheets.
The Ccode is has different parameters.
The Ccode in Input 1 can be eighter 1000200 or 1000120.
1000200 corresponds to SABB and SABB-2 AND 1000120to BASS
Column Ccode in Input 2 can be SABB, SABB-2 or BASS.

In the Lookup sheet, column C (nr. ) contains the formula
{=INDEX('INPUT 1'!$C$2:$C$65536,MATCH(A3,IF(LOOKUP!B$3:B$65536=B3,LOOKUP!A$3:A$65536),0))} which give sme the nr. corresponding to the Icode and Ccode of Input 1.

THE PROBLEM is using the formula to lookuo column H (nr) for Input 2.
If I use the same formula it does not work and disregards the multiple occurences.

Can anyone help me with a formula that will look at the Icode in columb B (Lookup Sheet), go to INPUT 2 and give me the corresponding nr.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
quote
that will look at the Icode in columb B (Lookup Sheet), go to INPUT 2 and give me the corresponding nr.
unquote

try this
in lookup sheet in cell C2 copy this formula
=INDEX(input2!$C:$C,MATCH(B2,input2!$B:$B,0),1)
you will get 11000
you can copy this formula down
 
Upvote 0
I forgot to tell you that index--match function will find ONLY THE FIRST occurence. If you want to consider more occurences of same value and corresponding Nr value then you should have a macro
please clarify this in your next posting.
 
Upvote 0
That is my point exactly....
The formula you gave me will give only the first occurence unless you match it.

This is the formula I use to find the values for Input 1. It works perfectly and NO VBA needed.

{=INDEX('INPUT 1'!$C$2:$C$65536,MATCH(A3,IF(LOOKUP!B$3:B$65536=B3,LOOKUP!A$3:A$65536),0))}

This formula does not work however with Input 2 due to complicated match values.

So let's say
I want in H14 in Lookup sheet the value that belongs to the second occurence of BB548790 matching BASS. Using the original formula will return 22960

!!!!!!So lookup BB548790 in Input 2 and return 64820. (second occurence in this case)!!!!!!

Any one has an idea on how to improve the formula to make it return that value instead of
22960.
 
Upvote 0
Can you just disregard the formulas that you have and state clearly in words what you want to happen on the LOOKUP sheet? You need to specify the givens (lookup values) on the LOOKUP sheet...
 
Upvote 0
Hello aladin...

In the lookup sheet (column H), I want Column B to be looked up, Go toInput sheet 2 and return the corresponding value. (column C)
 
Upvote 0
Hello aladin...

In the lookup sheet (column H), I want Column B to be looked up, Go toInput sheet 2 and return the corresponding value. (column C)

What is the big idea? Comparing [ nr. ] of INPUT 1 with that of INPUT 2? If so, is Ccode relevant for the comparison?
 
Upvote 0
Yes Aladin..comparing Input 1 with Input 2 and Ccode is relevant for comparison.
Only problem is that Input 1 uses different codes than Input 2.

!!note!!
1000200 in Input 1 corresponds with SAAB and SAAB-2 in input 2 and 1000120 with BASS
An Icode can have multiple occurence as seen.
ex. BB548790 has 3 occurences, (In Input 1 twice as 1000200 and once as 1000120) This is split up in Input 2 as SAAB-1, SAAB and as BASS!!
 
Upvote 0
I don't think you need the LOOKUP sheet...

D2 on INPUT 1...

Control+shift+enter, not just enter...
Code:
=INDEX('INPUT 2'!$C$2:$C$14,
    MATCH(1,IF(LOOKUP('INPUT 2'!$A$2:$A$14,
         {"BASS";"SABB";"SABB-2"},{1000120;1000200;1000200})=A2,
                 IF('INPUT 2'!$B$2:$B$14=B2,1)),0))

...and copy down.

It's essential that column A on INPUT 2 does only house values from {"BASS";"SABB";"SABB-2"} and nothing else.

E2 on INPUT 1

=C2=D2

...and copy down.

Yes Aladin..comparing Input 1 with Input 2 and Ccode is relevant for comparison.
Only problem is that Input 1 uses different codes than Input 2.

!!note!!
1000200 in Input 1 corresponds with SAAB and SAAB-2 in input 2 and 1000120 with BASS
An Icode can have multiple occurence as seen.
ex. BB548790 has 3 occurences, (In Input 1 twice as 1000200 and once as 1000120) This is split up in Input 2 as SAAB-1, SAAB and as BASS!!
 
Upvote 0
Thank you Aladin..It works.

Nice one since it also allows me to adjust it.

example. If SAAB-3 is added to the 1000200, I can make adjustments in the formula.

=INDEX('INPUT 2'!$C$2:$C$14,
MATCH(1,IF(LOOKUP('INPUT 2'!$A$2:$A$14,
{"BASS";"SABB";"SABB-2";"SABB-3";"etc"},1000120;1000200;1000200;1000200;etc})=A2,
IF('INPUT 2'!$B$2:$B$14=B2,1)),0))

Thank you....
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,112
Members
452,302
Latest member
TaMere

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