Linking data using IF, INDEX and MATCH

Colin39

New Member
Joined
Nov 4, 2011
Messages
3
Hi,
I have 2 tabs on a spreadsheet.
The first contains product codes and quantities and a reason code for shortages.
The second tab shows the buyer against each code
I am trying to return the quantity from sheet 1 if the code matches and the reason code is 2.
I can do the index and match function but am struggling to find a way to only return the result if the reason code is 2.

INDEX(Sheet2!K:K,MATCH($A127,Sheet2!G:G,0),)

Can anyone please advise how to link the result only if the reson code is 2
reason code is in column O on sheet 2

Many thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to MrExcel.

Try:

=if(Sheet2!O127="2",INDEX(Sheet2!K:K,MATCH($A127,Sheet2!G:G,0),),"")

I assumed your code you wanted to match was in O127, if not change that to the correct cell. Hope this helps.
 
Upvote 0
Reason code is always in column O but as there are multiple codes and reasons i need to look up against the entire range not just on a single cell
tab 1 will change each day as these are the items that have been shorted
and the reason code will change accordingly so I was thinking of using IF O:O = 2 but that doesnt work
 
Upvote 0
Control+shift+enter, not just enter:
Rich (BB code):
=INDEX(Sheet2!$K$2:$K$2000,MATCH(1,IF(Sheet2!$G$2:$G$2000=$A127,
    IF(Sheet2!$O$2:$O$2000=2,1)),0))
would return the first transaction qualified with reason code of 2.
 
Upvote 0

Forum statistics

Threads
1,222,404
Messages
6,165,856
Members
451,987
Latest member
Johnzdz

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