Excel formula to find matches in two columns

JENWPS

New Member
Joined
Nov 9, 2023
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I have 3 columns - Column A (Vendor), Column B(PO#), Column C(Product Line). I am trying to weed out PO's that meet certain criteria. As long as all of the DROP lines for a given PO have the same VENDOR it can be deleted. So if the VENDOR is the same for ALL DROP lines on a PO, I can disregard that PO all together regardless of the MISC lines. Is there a formula to show these matches? Below is an example with the desired outcome in column D.
COLUMN ACOLUMN BCOLUMN CCOLUMN D
VENDORPO#PRODUCT LINE
CONTIXO2401242DROPDISCARD
CONTIXO2401242DROPDISCARD
CONTIXO2401242DROPDISCARD
CONTIXO2401242DROPDISCARD
MATTEL2401242MISCDISCARD
KIDGAL2401242MISCDISCARD
CONTIXO2401246DROPKEEP
WONFOLD2401246DROPKEEP
STANS2401253DROPKEEP
ROYALG2401253DROPKEEP
STANS2401253MISCKEEP
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try this:

Dante Amor
ABCD
1VENDORPO#PRODUCT LINEDISCARD/KEEP
2CONTIXO2401242DROPDISCARD
3CONTIXO2401242DROPDISCARD
4CONTIXO2401242DROPDISCARD
5CONTIXO2401242DROPDISCARD
6MATTEL2401242MISCKEEP
7KIDGAL2401242MISCKEEP
8CONTIXO2401246DROPKEEP
9WONFOLD2401246DROPKEEP
10STANS2401253DROPKEEP
11ROYALG2401253DROPKEEP
12STANS2401253MISCKEEP
dam4
Cell Formulas
RangeFormula
D2:D12D2=IF(COUNTIFS(A:A,A2,B:B,B2,C:C,"DROP")=COUNTIFS(B:B,B2,C:C,"DROP"),"DISCARD","KEEP")
 
Upvote 0
Almost - I need it to take every line of the PO into consideration. For example, for PO# 2401242 (lines 2-7), since 4 of the lines are drop and all of the vendors match for those drop lines, I need to discard the whole PO including the MISC lines so ideally lines 2-7 in column D would say Discard. That I can sort the whole sheet and delete all 'discard' lines.
 
Upvote 0
Try in cell D2:

VBA Code:
=LET(a,A2:A12,b,B2:B12,c,C2:C12,IFERROR(IF(MATCH(COUNTIFS(b,b,c,"DROP"), COUNTIFS(a,UNIQUE(FILTER(a,b=b)),b,b,c,"DROP"),0),"DISCARD"),"KEEP"))
 
Upvote 0
Older Excel version (older than 2019 and 360)

Book1
ABCD
1VENDORPO#PRODUCT LINEDISCARD/KEEP
2CONTIXO2401242DROPdiscard
3CONTIXO2401242DROPdiscard
4CONTIXO2401242DROPdiscard
5CONTIXO2401242DROPdiscard
6MATTEL2401242MISCdiscard
7KIDGAL2401242MISCdiscard
8CONTIXO2401246DROPkeep
9WONFOLD2401246DROPkeep
10STANS2401253DROPkeep
11ROYALG2401253DROPkeep
12STANS2401253MISCkeep
Sheet1
Cell Formulas
RangeFormula
D2:D12D2=IF(SUMPRODUCT(IF($C$2:$C$12="DROP",IF($B$2:$B$12=B2,1/COUNTIFS($C$2:$C$12,"DROP",$B$2:$B$12,B2,$A$2:$A$12,$A$2:$A$12))))=1,"discard","keep")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Try in cell D2:

VBA Code:
=LET(a,A2:A12,b,B2:B12,c,C2:C12,IFERROR(IF(MATCH(COUNTIFS(b,b,c,"DROP"), COUNTIFS(a,UNIQUE(FILTER(a,b=b)),b,b,c,"DROP"),0),"DISCARD"),"KEEP"))
Is there a way to look at the entire column, not stop at line 12? This sheet has a different amount of lines each day.
 
Upvote 0
Is there a way to look at the entire column, not stop at line 12? This sheet has a different amount of lines each day.
12 is an example.

It is not recommended, in this type of formulas, to use the entire column, it could affect the performance of the sheet, but you can enter an estimated number, for example, if you use 2,000 rows, you can enter 5000.

Excel Formula:
=LET(a,A2:A5000,b,B2:B5000,c,C2:C5000,IFERROR(IF(MATCH(COUNTIFS(b,b,c,"DROP"), COUNTIFS(a,UNIQUE(FILTER(a,b=b)),b,b,c,"DROP"),0),"DISCARD"),"KEEP"))

😊
 
Upvote 0
Solution
12 is an example.

It is not recommended, in this type of formulas, to use the entire column, it could affect the performance of the sheet, but you can enter an estimated number, for example, if you use 2,000 rows, you can enter 5000.

Excel Formula:
=LET(a,A2:A5000,b,B2:B5000,c,C2:C5000,IFERROR(IF(MATCH(COUNTIFS(b,b,c,"DROP"), COUNTIFS(a,UNIQUE(FILTER(a,b=b)),b,b,c,"DROP"),0),"DISCARD"),"KEEP"))

😊
Perfect! Thank you so much for your help!!
 
Upvote 0
Perfect! Thank you so much for your help!!
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,223,634
Messages
6,173,474
Members
452,516
Latest member
archcalx

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