Index and Match with multiple criteria

Indominus

Board Regular
Joined
Jul 11, 2020
Messages
160
Office Version
  1. 2016
Platform
  1. Windows
Hello. The attached photo is just an example. So I have this workbook that has multiple sheets like this where I would have to run the same type of code. In one sheet I have at least two lookup values. Another sheet I have a file like the one attached. Referenced as Raw data. One lookup value which will be a person’s username will be in column A. I then have at least two numbers that I need to identify if the username has them attached. These are in column I in Raw data sheet. In the real sheet the lookup values, the username and two numbers, won’t be in column R but in my main sheet. If that matters. But what I need to be able to do is for example, is find
IF Bob has both 6383 and 9473, “pass”,”fail”. Basically an IF formula with this.

I have tried Index and match but it won’t work straight up since it will only find the first time Bob appears. I YouTubed this and it seems maybe I will have to use arrays or the small formula. Not 100% sure though. Any help would be very appreciated. Thank you in advance!
 

Attachments

  • 5C4E17AB-2BA0-42E2-9FF7-8BCB0F930A30.png
    5C4E17AB-2BA0-42E2-9FF7-8BCB0F930A30.png
    38.5 KB · Views: 20
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try

=IF((COUNTIFS(A:A,"bob",I:I,6383)>0)+(COUNTIFS(A:A,"bob",I:I,9473)>0)=2,"pass","fail")

M.
 
Upvote 0
Solution
Using cell references
=IF((COUNTIFS(A:A,S6,I:I,R3)>0)+(COUNTIFS(A:A,S6,I:I,R4)>0)=2,"pass","fail")

M.
 
Upvote 0
Another way:

=IF(SUMPRODUCT((A2:A20=S6)*((I2:I20=R3)+(I2:I20=R4)))=2,"pass","fail")

Note: You must limit the range of cells
 
Upvote 0
Dante,
I think your formula doesn't give the correct result if there are two instances Bob - 6383 (or Bob - 9473)

M.
 
Upvote 0
I think your formula doesn't give the correct result if there are two instances Bob - 6383 (or Bob - 9473)
Ah ok.Then

Dante Amor.xlsm
ABIJRST
1Id
2bob6383Pass
3john836386383Pass
4mary237389473
5nancy373
6bob9473bob
7bob9473
8nancy8472
Hoja6
Cell Formulas
RangeFormula
T2T2=IF(SUMPRODUCT((A2:A20=S6)*((I2:I20=R3)+(I2:I20=R4)))>=2,"Pass","Fail")
T3T3=IF(COUNTIFS(A:A,S6,I:I,R3)+COUNTIFS(A:A,S6,I:I,R4)>=2,"Pass","Fail")
 
Last edited:
Upvote 0
Pasta1
ABCDEFGHI
1IDMy FormulaYour FormulaNumber
2bobfailpass6383
3john83638
4may23738
5nancy373
6david3838
7bob6383
8nancy8472
Plan3
Cell Formulas
RangeFormula
C2C2=IF((COUNTIFS(A:A,"bob",I:I,6383)>0)+(COUNTIFS(A:A,"bob",I:I,9473)>0)=2,"pass","fail")
D2D2=IF(SUMPRODUCT((A2:A20=S6)*((I2:I20=R3)+(I2:I20=R4)))=2,"pass","fail")


M.
 
Upvote 0
Thanks, I already saw it. Then

=IF(SUMPRODUCT((A2:A20=S6)*((I2:I20=R3)+(I2:I20=R4)))>=2,"Pass","Fail")

Or

=IF(COUNTIFS(A:A,S6,I:I,R3)+COUNTIFS(A:A,S6,I:I,R4)>=2,"Pass","Fail")
 
Upvote 0
I don't know if such a scenario is possible in the real case, but we are still getting different results

Pasta1
ABCDEFGHI
1IDMy FormulaYour New F1Your New F2Number
2bobfailPassPass6383
3john83638
4may23738
5nancy373
6david3838
7bob6383
8nancy8472
Plan3
Cell Formulas
RangeFormula
C2C2=IF((COUNTIFS(A:A,S6,I:I,R3)>0)+(COUNTIFS(A:A,S6,I:I,R4)>0)=2,"pass","fail")
D2D2=IF(SUMPRODUCT((A2:A20=S6)*((I2:I20=R3)+(I2:I20=R4)))>=2,"Pass","Fail")
E2E2=IF(COUNTIFS(A:A,S6,I:I,R3)+COUNTIFS(A:A,S6,I:I,R4)>=2,"Pass","Fail")


M.
 
Upvote 0
You are right, it is a case and if it is presented my formula is not correct.
Also your formula is faster, I vote for your formula. Thanks for comment.
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,151
Members
449,068
Latest member
shiz11713

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