Index Match Return values if multiple array conditions are met

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,113
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Given in A1:
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri,sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { text-align: center; }</style>
identifierR1
R2R3R4
yes16
155453
23151255
yes34
145450
555610089
yes80
313224
45788393

<colgroup><col style="width:65pt" span="5" width="65"> </colgroup><tbody>
</tbody>

formula in A2 is =IF(AND(B2>C2,D2>E2),"yes","") hence conditions for the row are R1 superior to R2 AND R3 superior to R4.

Result Expected in G1:
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri,sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { text-align: center; }</style>
R1_r
R2_r
R3_r
R4_r
resultyes16155453
yes34145450
yes80313224

<colgroup><col style="width:65pt" span="6" width="65"> </colgroup><tbody>
</tbody>
formula presently used in H2 is =IF(ROWS($H$2:H2)>SUMPRODUCT(--(B:B>C:C),--(D:D>E:E)),"","yes") CSE copied down till needed
formula presently used in I2 is =IF(ROWS(I$2:I2)>SUMPRODUCT(--($B:$B>$C:$C),--($D:$D>$E:$E)),"",INDEX(B:B,SMALL(IF($A$2:$A$7=$H2,ROW($A$2:$A$7)),ROWS(I$2:I2)))) CSE copied right till Column L and down till needed.

NOTE:
The above scenario in A1 involves the use of a helper column in A returning either a 'yes' or a blank
The above results in G1 make use of Column A in order to retrieve all INDEX whenever the condition is met

QUESTION:
Could it be possible to invoke the two conditions within the search formula thus removing the need of Column A while returning all values fitting the conditions:
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 12pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Calibri,sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { text-align: center; }</style>
count3R1R2R3R4
Result
16155453
34145450
80313224

<colgroup><col style="width:65pt" span="6" width="65"> </colgroup><tbody>
</tbody>

Count would be =SUMPRODUCT(--(B:B>C:C),--(D:D>E:E)) CSE
but what would be the formula in I2?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
An efficient set up would be:

R1
R2
R3
R4
Idx
R1
R2
R3
R4
16
15
54
53
1
16
15
54
53
23
15
12
55
3
34
14
54
50
34
14
54
50
5
80
31
32
24
55
56
100
89
80
31
32
24
45
78
83
93

<TBODY>
</TBODY>

Data is located in B1:E7, with headers in B1:E1; the processing in G:K.

G2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IFERROR(SMALL(IF(($B$2:$B$7>$C$2:$C$7)*($D$2:$D$7>$E$2:$E$7),
  ROW($B$2:$B$7)-ROW($B$2)+1),ROWS($G$2:G2)),"")

H2, just enter, copy across, and down:
Rich (BB code):
=IF($G2="","",INDEX(B$2:B$7,$G2))
 
Upvote 0
Rich (BB code):
=IFERROR(SMALL(IF(($B$2:$B$7>$C$2:$C$7)*($D$2:$D$7>$E$2:$E$7),
  ROW($B$2:$B$7)-ROW($B$2)+1),ROWS($G$2:G2)),"")

Rich (BB code):
=IF($G2="","",INDEX(B$2:B$7,$G2))

Would it be a problem If we used the whole Column Range? would it possibly trigger conflict within Excel or would it be acceptable such as in Sheet2:
Rich (BB code):
=IFERROR(SMALL(IF((Sheet1!B:B>Sheet1!C:C)*(Sheet1!D:D>Sheet1!E:E),
  ROW(Sheet1!B:B)-ROW($A$2)+1),ROWS(A$2:$A2)),"")
and
Rich (BB code):
=IF($A2="","",INDEX(Sheet1!B:B,$A2+1))

Your solution is very elegant.
The addition of conditions would be to be taken care here right?

Rich (BB code):
=IFERROR(SMALL(IF((range1 condition_1 range2)*(range3 condition_2 range4)*(rangex condition_n rangey),   ROW(range)-ROW($B$2)+1),ROWS($G$2:G2)),"")
</pre>
 
Upvote 0
Yes. It would adversely affect the efficiency. A better alternative is to use dynamic named ranges.

Aladin, Thank you for the fast and concise reply.
it is exactly what I was looking for. I should have thought of the row as a medium to get to correct answer...

Thanks again, it is perfect.
 
Upvote 0

Forum statistics

Threads
1,215,450
Messages
6,124,912
Members
449,195
Latest member
Stevenciu

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