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).

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][TABLE="width: 280"]
<tbody>[TR]
[TD="class: xl66, width: 280, align: right"]X ->[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 40"]
<tbody>[TR]
[TD="width: 40"]small[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 38"]
<tbody>[TR]
[TD="width: 38"]large[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][TABLE="width: 280"]
<tbody>[TR]
[TD="class: xl66, width: 280, align: right"]Y ->[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 40"]
<tbody>[TR]
[TD="width: 40"]tiny[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 38"]
<tbody>[TR]
[TD="width: 38"]giant[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][TABLE="width: 280"]
<tbody>[TR]
[TD="class: xl65, width: 280"]this castle is small with large windows into which giants may peer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][TABLE="width: 40"]
<tbody>[TR]
[TD="width: 40"]small[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 38"]
<tbody>[TR]
[TD="width: 38"]large[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][TABLE="width: 40"]
<tbody>[TR]
[TD="width: 40"]tiny[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 38"]
<tbody>[TR]
[TD="width: 38"]giant[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][TABLE="width: 280"]
<tbody>[TR]
[TD="class: xl65, width: 280"]this castle is small with large windows into which giants may peer[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
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,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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