Matching on multiple criteria

Vikram J B

New Member
Joined
Jun 25, 2018
Messages
5
The Input Values to be entered ..IN F2 & F4. The Value in F2 needs to be searched in the array G14:K19 AND the value Entered in F4 needs to be searched in the array L14:P19. If both the values are found on the same Row and corresponding columns , We need the corresponding Model to be returned. There is an instance of F2 in K12 of the Head Range array but the corresponding cell to it in the Corresponding Discharge Value Array is P12 is not equal to F4 and hence needs to be ignored. Only the cells matching F2 head range array and F4 Matching cells lying in the same column and row no as F2 in the head Range should return the value of the model in column E


[TABLE="class: cms_table, width: 979"]
<tbody>[TR]
[TD][/TD]
[TD="colspan: 4"]Criteria to Select Pumpsets[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]Input Head due to all causes[/TD]
[TD]110[/TD]
[TD]in Mtrs[/TD]
[TD][/TD]
[TD][/TD]
[TD][/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]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]Input Required Discharge[/TD]
[TD]400[/TD]
[TD]in LPM[/TD]
[TD][/TD]
[TD][/TD]
[TD][/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]
[TD][/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]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="colspan: 5"]Head Range[/TD]
[TD="colspan: 5"]Discharge Range[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]SERIES[/TD]
[TD]MODEL[/TD]
[TD]STG[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RE68[/TD]
[TD]RE68/03+ET075[/TD]
[TD]3[/TD]
[TD]62[/TD]
[TD]60[/TD]
[TD]57[/TD]
[TD]53[/TD]
[TD]47[/TD]
[TD]0[/TD]
[TD]210[/TD]
[TD]300[/TD]
[TD]390[/TD]
[TD]480[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RE68[/TD]
[TD]RE68/04+ET093[/TD]
[TD]4[/TD]
[TD]82[/TD]
[TD]80[/TD]
[TD]76[/TD]
[TD]70[/TD]
[TD]62[/TD]
[TD]0[/TD]
[TD]210[/TD]
[TD]300[/TD]
[TD]390[/TD]
[TD]480[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RE65[/TD]
[TD]RE65/05 + ET093[/TD]
[TD]5[/TD]
[TD]98[/TD]
[TD]97[/TD]
[TD]96[/TD]
[TD]94[/TD]
[TD]91[/TD]
[TD]0[/TD]
[TD]150[/TD]
[TD]200[/TD]
[TD]250[/TD]
[TD]300[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RE65[/TD]
[TD]RE65/06 + ET112[/TD]
[TD]6[/TD]
[TD]118[/TD]
[TD]116[/TD]
[TD]114[/TD]
[TD]113[/TD]
[TD]110[/TD]
[TD]0[/TD]
[TD]150[/TD]
[TD]200[/TD]
[TD]250[/TD]
[TD]300[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RE70[/TD]
[TD]RE70/06 + ET150[/TD]
[TD]6[/TD]
[TD]114[/TD]
[TD]111[/TD]
[TD]110[/TD]
[TD]109[/TD]
[TD]103[/TD]
[TD]0[/TD]
[TD]300[/TD]
[TD]400[/TD]
[TD]500[/TD]
[TD]600[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]RE70[/TD]
[TD]RE70/07 + ET187[/TD]
[TD]7[/TD]
[TD]133[/TD]
[TD]129[/TD]
[TD]128[/TD]
[TD]127[/TD]
[TD]120[/TD]
[TD]0[/TD]
[TD]300[/TD]
[TD]400[/TD]
[TD]500[/TD]
[TD]600[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/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]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This?


Excel 2010
BCDEFGHIJKLMN
1Criteria to Select Pumpsets
2Input Head due to all causes110in MtrsRE70/06 + ET150
3
4Input Required Discharge400in LPM
5
6
7Head RangeDischarge Range
8SERIESMODELSTG1234512345
9RE68RE68/03+ET075362605753470210300390480
10RE68RE68/04+ET093482807670620210300390480
11RE65RE65/05 + ET093598979694910150200250300
12RE65RE65/06 + ET11261181161141131100150200250300
13RE70RE70/06 + ET15061141111101091030300400500600
14RE70RE70/07 + ET18771331291281271200300400500600
Sheet1


Code:
Sub findcell()
Dim c As Range
For Each c In Range("e9:n14")
If c = Range("d2") And c.Offset(0, 5) = Range("d4") Then
Range("g2") = Cells(c.Row, 3)
End If
Next c
End Sub
 
Upvote 0

Excel 2010
BCDEFGHIJKLMN
1Criteria to Select Pumpsets
2Input Head due to all causes110in MtrsRE70/06 + ET150
3
4Input Required Discharge400in LPM
5
6
7Head RangeDischarge Range
8SERIESMODELSTG1234512345
9RE68RE68/03+ET075362605753470210300390480
10RE68RE68/04+ET093482807670620210300390480
11RE65RE65/05 + ET093598979694910150200250300
12RE65RE65/06 + ET11261181161141131100150200250300
13RE70RE70/06 + ET15061141111101091030300400500600
14RE70RE70/07 + ET18771331291281271200300400500600
Sheet1
Cell Formulas
RangeFormula
G2=INDEX($C$9:$C$14,SUMPRODUCT(--($E$9:$I$14=D2)*--(OFFSET($E$9:$I$14,0,5)=D4)*ROW($E$9:$I$14))-8)
 
Upvote 0
Thanks very much .... But what is the -8 at the end of the formula ...

Is it OK to simply copy and past the formula to the excel sheet ? or do i need to do anything else, as i am getting a ref# error.

Incase I need to search for multiple value meeting the 2 input Criterias, then how do i find it from 10000+ records like this.

Thanks in advance ...
 
Upvote 0
The header above is in row 8, otherwise subtract a different number (be sure the columns line up also to avoid error messages). I wrote a macro first in case you have multiple values. Formulas won't work well with 10000+ records unless you're willing to put the data in a normal (1 to 1) structure.
 
Last edited:
Upvote 0
Here's the code for multiple rows:

Code:
Sub findcell()
Dim c As Range, x%
x = 0
For Each c In Range("e9:n14")
If c = Range("d2") And c.Offset(0, 5) = Range("d4") Then
Range("p2").Offset(x) = Cells(c.Row, 3)
x = x + 1
Else
End If
Next c
End Sub

If you want to try a formula, something like:


Excel 2010
BCDEFGHIJKLMNOP
1Criteria to Select PumpsetsRE68/04+ET093
2Input Head due to all causes110in MtrsRE70/06 + ET150
3
4Input Required Discharge400in LPM
5
6
7Head RangeDischarge Range
8SERIESMODELSTG1234512345
9RE68RE68/03+ET075362605753470210300390480
10RE68RE68/04+ET0934828076701100210300390400
11RE65RE65/05 + ET093598979694910150200250300
12RE65RE65/06 + ET11261181161141131100150200250300
13RE70RE70/06 + ET15061141111101091030300400500600
14RE70RE70/07 + ET18771331291281271200300400500600
Sheet1 (3)
Cell Formulas
RangeFormula
P1{=INDEX($C$9:$C$14,SMALL(IF($E$9:$I$14=$D$2,IF(OFFSET($E$9:$I$14,0,5)=$D$4,ROW($E$9:$I$14))),ROW(A1))-8)}
Press CTRL+SHIFT+ENTER to enter array formulas.


which might be slow
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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