Search row for 4 criteria - return row if all criteria is met

Doodle24

New Member
Joined
Aug 4, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have tried to formulate something that searches through rows to meet 4 criterias. If all criteria is met I need the row number or the entire row returned, if not continue the search. Half of my criteria is straight forward BLUE=BLUE, GREEN=GREEN while the other two needs to be within a range. For example, 1 day +- from a specific date in a cell or +-500 from a specific number in a cell. I usually use if loops, vlookup and index/match but it seems I have to get into VBA with this.. Any suggestions? Thanks so much for any ideas on how to tackle this!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to the Forum!

With Excel 365, you could use the FILTER function to return all rows meeting your criteria:

ABCDEFGH
1Find
2Test1Test2Test3Test1Blue
3BlueGreen6Test2Green
4YellowOrange9Test 3Min5
5YellowOrange23Max10
6BlueOrange-1
7BlueGreen2Results
8YellowYelllow6BlueGreen6
9BlueGreen7BlueGreen7
10RedYelllow8
11
Sheet1
Cell Formulas
RangeFormula
F8:H9F8=FILTER(B3:D10,(B3:B10=G2)*(C3:C10=G3)*(D3:D10>=H4)*(D3:D10<=H5))
Dynamic array formulas.
 
Upvote 0
Thank you so much for the reply!!

I did try it out but I get the number value# error. I read that the data rows must equal the argument row.. I'm trying to bring in a row with additional cells (around 10-15 cells) from my 4 criteria cells- can that be the issue? Do you know any workarounds? Thanks
 
Upvote 0
Welcome to the Forum!

With Excel 365, you could use the FILTER function to return all rows meeting your criteria:

ABCDEFGH
1Find
2Test1Test2Test3Test1Blue
3BlueGreen6Test2Green
4YellowOrange9Test 3Min5
5YellowOrange23Max10
6BlueOrange-1
7BlueGreen2Results
8YellowYelllow6BlueGreen6
9BlueGreen7BlueGreen7
10RedYelllow8
11
Sheet1
Cell Formulas
RangeFormula
F8:H9F8=FILTER(B3:D10,(B3:B10=G2)*(C3:C10=G3)*(D3:D10>=H4)*(D3:D10<=H5))
Dynamic array formulas.

Thank you so much for the reply!!

I did try it out but I get the number value# error. I read that the data rows must equal the argument row.. I'm trying to bring in a row with additional cells (around 10-15 cells) from my 4 criteria cells- can that be the issue? Do you know any workarounds? Thanks
 
Upvote 0
Can you please post a sample of your data, so we can better understand what you're trying to do.

It's best if you can do this using the XL2BB add-in: XL2BB - Excel Range to BBCode so that we can copy directly into a test workbook.
 
Upvote 0
Sorry for not stating my problem clearly. I'll get XL2BB in the future but got some constraints on my computer right now so I took a snippet of what I'm trying to accomplish.

I have 2 data sets with data that needs to be compared and additional data (data that won't be compared but we still need to keep it). I need to pair the rows based on the 4 criteria. They are color coded. If the 4 criteria match - I would need to bring in the row matches and pair it to the other. I got thousands of rows in my original sheets and most of the rows won't match each other and will be discarded.

1659909417139.png

Any suggestions would be much appreciated!
 
Upvote 0
Will your datasets always pair so neatly?

I'd start the analysis along these lines:

ABCDEFGHIJKLM
1Possible
2CostIDDateLengthColour1Colour2LocationMatches?
3695123413 May 20226820GreenVioletNYABCDEFGH
4BlahBlahBlahBlahBlahBlahBlahn/a
5
6Possible
7MinDateDateMaxDateMinLLMaxLColour1Colour2IDNameMatches?
81 May 202231 May 2022GreenVioletABCD1234
9BluhBluhBluhBluhBluhBluhBluhBluhBluhBluhn/a
105 May 202217 May 2022GreenVioletEFGH1234
Sheet1
Cell Formulas
RangeFormula
I3:J3,I4I3=TRANSPOSE(FILTER(J$8:J$10,(H$8:H$10=F3)*(I$8:I$10=G3)*(B$8:B$10<=D3)*(D$8:D$10>=D3),"n/a"))
L8:L10L8=TRANSPOSE(FILTER(C$3:C$4,(F$3:F$4=H8)*(G$3:G$4=I8)*(D$3:D$4>=B8)*(D$3:D$4<=D8),"n/a"))
Dynamic array formulas.
 
Upvote 0
Solution
Will your datasets always pair so neatly?

I'd start the analysis along these lines:

ABCDEFGHIJKLM
1Possible
2CostIDDateLengthColour1Colour2LocationMatches?
3695123413 May 20226820GreenVioletNYABCDEFGH
4BlahBlahBlahBlahBlahBlahBlahn/a
5
6Possible
7MinDateDateMaxDateMinLLMaxLColour1Colour2IDNameMatches?
81 May 202231 May 2022GreenVioletABCD1234
9BluhBluhBluhBluhBluhBluhBluhBluhBluhBluhn/a
105 May 202217 May 2022GreenVioletEFGH1234
Sheet1
Cell Formulas
RangeFormula
I3:J3,I4I3=TRANSPOSE(FILTER(J$8:J$10,(H$8:H$10=F3)*(I$8:I$10=G3)*(B$8:B$10<=D3)*(D$8:D$10>=D3),"n/a"))
L8:L10L8=TRANSPOSE(FILTER(C$3:C$4,(F$3:F$4=H8)*(G$3:G$4=I8)*(D$3:D$4>=B8)*(D$3:D$4<=D8),"n/a"))
Dynamic array formulas.
Thanks Stephen! I'll give the formula a try in a bit. No, my data does not pair that nicely.. I got thousands of rows in one sheet with "additional" data that I won't use but the other data sheet is complete and needs to be matched. I wanted to show the logic behind what I'm trying to accomplish.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Search dataset rows for multiple criteria and combine rows if multiple criteria is met
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Search dataset rows for multiple criteria and combine rows if multiple criteria is met
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Thanks, I'll do that in the future! Should have read the guidelines closer.
 
Upvote 0

Forum statistics

Threads
1,216,303
Messages
6,129,983
Members
449,548
Latest member
lharr28

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