IF AND formula, returns "Yes" if column matches a cell reference and 2nd column starts with first 3 characters in a reference list

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
929
Office Version
  1. 365
Platform
  1. Windows
I am needing help with a IF AND formula.
I am looking to return a "Yes" if Column A Matches G2 and if anything in Column B starts with the first 3 characters from a reference list in Column F.
See below example with desired result in column C.

Thank you to anyone who can help with this.

Book1
ABCDEFG
1CompanyReference #If is Blue Company and Reference starts with List Ref.ReferenceCompany
2Blue CompanyCAE51126YesCAEBlue Company
3Red CompanyDTY8852NoCAC
4Blue CompanyRRW9543NoCAG
5Blue CompanyCAT1137YesCAT
6Red CompanyJEQ8842No
7Blue CompanyCAC84255Yes
8Blue CompanyCAG745Yes
9Red CompanyCAC7562No
Sheet1
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
How about:

Excel Formula:
=IF(AND(A2=$G$2,SUM(--(LEFT(B2,3)=$F$2:$F$5))),"Yes","No")
 
Upvote 0
Another option
Excel Formula:
=IF(AND(A2=$G$2,ISNUMBER(XMATCH(LEFT(B2,3),$F$2:$F$10))),"Yes","No")
 
Upvote 0
How about:

Excel Formula:
=IF(AND(A2=$G$2,SUM(--(LEFT(B2,3)=$F$2:$F$5))),"Yes","No")
If I had to expand the list in column F to include items with only 2 characters, how would I modify this formula? (see below example - want C8 to be Yes)

Book1
ABCDEFG
1CompanyReference #If is Blue Company and Reference starts with List Ref.ReferenceCompany
2Blue CompanyCAE51126YesCAEBlue Company
3Red CompanyDTY8852NoCAC
4Blue CompanyRRW9543NoCAG
5Blue CompanyCAT1137YesCAT
6Red CompanyJEQ8842NoAE
7Blue CompanyCAC84255YesAC
8Blue CompanyAT5745NoAT
9Red CompanyCAC7562NoAG
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=IF(AND(A2=$G$2,SUM(--(LEFT(B2,3)=$F$2:$F$9))),"Yes","No")
 
Upvote 0
You can try:
Excel Formula:
=IF(SUM((A2=$G$2)*COUNTIFS(B2,$F$2:$F$9&"*")),"Yes","No")

Or (edit):
Excel Formula:
=IF(SUM(COUNTIFS(B2,$F$2:$F$9&"*",A2,$G$2)),"Yes","No")
 
Upvote 0
Solution
You can try:
Excel Formula:
=IF(SUM((A2=$G$2)*COUNTIFS(B2,$F$2:$F$9&"*")),"Yes","No")

Or (edit):
Excel Formula:
=IF(SUM(COUNTIFS(B2,$F$2:$F$9&"*",A2,$G$2)),"Yes","No")
Thank you! This is perfect!
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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