If X exists in $A3 and Y does not exist in $A3 then display Y

ccjejohnson

New Member
Joined
Jul 16, 2018
Messages
3
I'm trying to compose a formula for if X exists in $A4 and Y does not exist in $A4 then insert Y

Please see sample spreadsheet snippet below. The closest I've come is =IF(ISNUMBER(SEARCH(B$2,$A4)),B$3,"") which only checks if X exists then inserts Y. Having trouble with the "does not exist" part. Any ideas? I'm using Excel 2016 (not Office365).

1ABC
2
X ->

<tbody>
</tbody>
small

<tbody>
</tbody>
large

<tbody>
</tbody>
3
Y ->

<tbody>
</tbody>
tiny

<tbody>
</tbody>
giant

<tbody>
</tbody>
4
this castle is small with large windows into which giants may peer

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
My snippet and sample formula in the original post is a bit off. Here's another version that's more aligned with the thread subject.

If B$1 exists in $A3 and B$2 does not exist in $A3 then display B$2 in B$3

ABC
1
small

<tbody>
</tbody>
large

<tbody>
</tbody>
2
tiny

<tbody>
</tbody>
giant

<tbody>
</tbody>
3
this castle is small with large windows into which giants may peer

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Does this send you on the right track?

Code:
=IF(AND(ISNUMBER(FIND(B1,A3)),NOT(ISNUMBER(FIND(B2,A3)))),B2,"")
 
Upvote 0
Thanks for the reply! I managed to get an answer on another forum that solved the equation (see below), but yours looks to work just as well. Thanks again!

=IF(AND(COUNTIF($A3,"*"&B$1&"*")>0,COUNTIF($A3,"*"&B$2&"*")=0),B$2,"")
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,272
Members
449,219
Latest member
daynle

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